-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
100 lines (91 loc) · 2.83 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
{
description = "Lorenz Leutgeb's Flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
sops = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
vscode-server = {
url = "github:msteen/nixos-vscode-server";
inputs.nixpkgs.follows = "nixpkgs";
};
lorenz = {
url = "github:lorenzleutgeb/nur";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{ self, nixpkgs, home-manager, vscode-server, sops, lorenz, ... }:
with builtins;
with nixpkgs;
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
makeDiskImage = (import "${nixpkgs}/nixos/lib/make-disk-image.nix");
kebabCaseToCamelCase =
replaceStrings (map (s: "-${s}") lib.lowerChars) lib.upperChars;
importDirToAttrs = dir:
listToAttrs (map (name: {
name = kebabCaseToCamelCase (lib.removeSuffix ".nix" name);
value = import (dir + "/${name}");
}) (attrNames (readDir dir)));
nixosSystemFor = preconfig:
lib.nixosSystem {
inherit system;
specialArgs.inputs = inputs;
modules = [
nixpkgs.nixosModules.notDetected
home-manager.nixosModules.home-manager
sops.nixosModules.sops
({ config, ... }: {
home-manager = {
useGlobalPkgs = true;
useUserPackages = false;
backupFileExtension = "bak";
extraSpecialArgs = {
inputs = inputs;
super = config;
};
};
})
{
system.stateVersion = "23.05";
system.configurationRevision =
pkgs.lib.mkIf (self ? rev) self.rev;
nixpkgs = { inherit pkgs; };
nix.registry.nixpkgs.flake = nixpkgs;
}
preconfig
];
};
in rec {
packages.${system} = {
nc = makeDiskImage {
inherit pkgs;
inherit (pkgs) lib;
diskSize = "auto"; # 240 * 1000 * 1000 * 1000; # 240GB
format = "qcow2";
config = nixosConfigurations.nc.config;
};
live = nixosConfigurations.live.config.system.build.isoImage;
};
nixosConfigurations =
((mapAttrs (id: _: nixosSystemFor (import (./os/host + "/${id}")))
(readDir ./os/host))) // {
live = lib.nixosSystem {
inherit system;
modules = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-gnome.nix"
];
};
};
};
}