-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.nix
66 lines (51 loc) · 1.55 KB
/
shell.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
{ sources ? import ./sources.nix }:
let
pkgs = import sources.nixpkgs { };
isDarwin = pkgs.stdenvNoCC.isDarwin;
niv = pkgs.symlinkJoin {
name = "niv";
paths = [ sources.niv ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/niv \
--add-flags "--sources-file ${toString ./sources.json}"
'';
};
configuration = if isDarwin then ~/.nixpkgs/darwin-configuration.nix else /etc/nixos/configuration.nix;
overlays = "$dotfiles/overlays";
darwinRebuild = pkgs.writeShellScriptBin "rebuild" ''
set -e
export dotfiles="$(nix-build --no-out-link)"
${lint}/bin/lint
${format}/bin/format
darwin-rebuild switch --show-trace \
-I darwin=${sources.nix-darwin} \
-I nixpkgs=${sources.nixpkgs} \
-I darwin-config=${configuration} \
-I nixpkgs-overlays=${overlays}
'';
nixosRebuild = pkgs.writeShellScriptBin "rebuild" ''
set -e
export dotfiles="$(nix-build --no-out-link)"
${lint}/bin/lint
${format}/bin/format
sudo nixos-rebuild switch --show-trace \
-I nixpkgs=${sources.nixpkgs} \
-I nixos-config=${configuration} \
-I nixpkgs-overlays=${overlays}
'';
rebuild = if isDarwin then darwinRebuild else nixosRebuild;
files = "$(find . -name '*.nix')";
format = pkgs.writeShellScriptBin "format" "nixpkgs-fmt ${files}";
lint = pkgs.writeShellScriptBin "lint" "nix-linter ${files} && echo No lint errors!";
in
pkgs.mkShell {
buildInputs = [
pkgs.nixpkgs-fmt
pkgs.nix-linter
niv
rebuild
format
lint
];
}