-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
118 lines (104 loc) · 3.55 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{
description = "hugolgst/nix-darwin";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-23.11-darwin";
nix-darwin.url = "github:LnL7/nix-darwin";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager/release-23.11";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ self, nix-darwin, nixpkgs, home-manager }:
let
hostname = "Hugo-Work-Macbook-Pro";
username = "hugolageneste";
home = "/Users/${username}";
flakePath = "${home}/.config/nix-darwin";
configuration = { pkgs, lib, ... }: {
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages = with pkgs; [
# Utils
git
coreutils
gnupg
jq
nerdfonts
# Gadgets
neofetch
pfetch-rs
vscode
iterm2
oh-my-fish
# Nix stuff
nixfmt
nixpkgs-review
nodejs_20
];
nixpkgs = {
config = {
allowUnfree = true;
};
};
nix.settings.experimental-features = [ "nix-command" "flakes" ];
services.nix-daemon.enable = true;
# Set fish as default shell
programs.fish = {
enable = true;
shellAliases = {
nce = "nvim ${flakePath}/flake.nix";
ncu = "nix flake update ${flakePath}; darwin-rebuild switch --flake ${flakePath}";
ncp = "cd ${flakePath}; git add -A; git commit -m \"Update nixpkgs to \$(jq -r '.nodes.nixpkgs.locked.rev' ${flakePath}/flake.lock)\"; git push";
ss = "open -b com.apple.ScreenSaver.Engine";
};
loginShellInit = ''
pfetch
'';
};
users.users."${username}" = {
shell = pkgs.fish;
inherit home;
};
system.activationScripts.postActivation.text = ''
# Set the default shell as fish for the user
sudo chsh -s ${lib.getBin pkgs.fish}/bin/fish ${username}
rm -r ${home}/.local/share/omf
su ${username} -c 'sudo ${lib.getBin pkgs.oh-my-fish}/bin/omf-install' # Dirty but didnt found another way
sourcePath="${flakePath}/config/iterm2.json"
destinationPath="${home}/Library/Application Support/iTerm2/DynamicProfiles/iterm2.json"
if [ ! -f "$destinationPath" ]; then
cp "$sourcePath" "$destinationPath"
fi
'';
# Enable sudo login with Touch ID
security.pam.enableSudoTouchIdAuth = true;
# MacOS system defaults
system.defaults = {
finder.AppleShowAllExtensions = true;
screensaver.askForPassword = true;
NSGlobalDomain."com.apple.swipescrolldirection" = false;
};
system.configurationRevision = self.rev or self.dirtyRev or null;
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 4;
nixpkgs.hostPlatform = "x86_64-darwin";
};
in
{
# Build darwin flake using:
# $ darwin-rebuild build --flake .#
darwinConfigurations.${hostname} = nix-darwin.lib.darwinSystem {
modules = [
configuration
home-manager.darwinModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.${username} = import ./home;
}
];
};
# Expose the package set, including overlays, for convenience.
darwinPackages = self.darwinConfigurations.${hostname}.pkgs;
};
}