-
Notifications
You must be signed in to change notification settings - Fork 5
/
flake.nix
97 lines (91 loc) · 3.63 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
lanzaboote.url = "github:nix-community/lanzaboote";
nix-index-database.url = "github:nix-community/nix-index-database";
};
outputs = { self, nixpkgs, home-manager, flake-utils, lanzaboote, nix-index-database, ... } @ inputs:
let
username = "bob.vanderlinden";
defaultOverlays = with self.overlays; [ default workarounds ];
mkPkgs =
{ system ? "x86_64-linux"
, nixpkgs ? inputs.nixpkgs
, config ? { allowUnfree = true; }
, overlays ? defaultOverlays
, ...
} @ options: import nixpkgs (options // {
inherit system config overlays;
});
in {
overlays.default = final: prev: import ./packages { pkgs = final; };
overlays.workarounds = final: prev: {
};
nixosModules =
import ./system/modules
// {
overlays = { nixpkgs.overlays = defaultOverlays; };
hardware-configuration = import ./system/hardware-configuration.nix;
system-configuration = import ./system/configuration.nix;
single-user = { suites.single-user.user = username; };
inherit (lanzaboote.nixosModules) lanzaboote;
# inherit (nix-index-database.nixosModules) nix-index;
nix-index-database-home-manager = { home-manager.sharedModules = [ nix-index-database.hmModules.nix-index ]; };
};
# System configuration for laptop.
nixosConfigurations.nac44250 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit inputs;
};
modules = builtins.attrValues self.nixosModules;
};
homeConfigurations."${username}@nac44250" = self.nixosConfigurations.nac44250.config.home-manager.users.${username}.home;
}
# Define outputs that allow multiple systems with for all default systems.
# This is to support OSX and RPI.
// flake-utils.lib.eachDefaultSystem (system:
let
pkgs = mkPkgs {
inherit system;
};
in
{
packages =
let
lib = pkgs.lib;
in
lib.filterAttrs (name: package: (package ? meta) -> (package.meta ? platforms) -> builtins.elem system package.meta.platforms) (import ./packages { inherit pkgs; });
apps.switch = {
type = "app";
program = let
switch = pkgs.writeShellApplication {
name = "switch";
text = ''
nom build --impure --keep-going --out-link system-result ${self}#nixosConfigurations."$(hostname)".config.system.build.toplevel
nom build --keep-going --out-link home-result ${self}#nixosConfigurations."$(hostname)".config.home-manager.users.\""$USER"\".home.activationPackage
./home-result/activate
if [[ "$(readlink --canonicalize system-result)" != "$(readlink --canonicalize /nix/var/nix/profiles/system)" ]]
then
${pkgs.coin}/bin/coin
sudo nix-env -p /nix/var/nix/profiles/system --set "$(readlink system-result)"
sudo system-result/bin/switch-to-configuration switch
fi
'';
runtimeInputs = [ pkgs.nix-output-monitor ];
};
in "${switch}/bin/switch";
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
nixpkgs-fmt
nixd
];
};
});
}