-
Notifications
You must be signed in to change notification settings - Fork 19
/
flake.nix
76 lines (66 loc) · 2.57 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
{
inputs = {
nixpkgs.url = "github:rhelmot/nixpkgs/nixbsd-dev";
lix = {
url = "git+https://git.lix.systems/artemist/lix.git?ref=freebsd-build";
inputs.nixpkgs.follows = "nixpkgs";
# We don't need another nixpkgs clone, it won't evaluate anyway
inputs.nixpkgs-regression.follows = "nixpkgs";
};
mini-tmpfiles = {
url = "github:nixos-bsd/mini-tmpfiles";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
};
nixConfig = {
extra-substituters = [ "https://attic.mildlyfunctional.gay/nixbsd" ];
extra-trusted-public-keys =
[ "nixbsd:gwcQlsUONBLrrGCOdEboIAeFq9eLaDqfhfXmHZs1mgc=" ];
};
outputs = { self, nixpkgs, lix, mini-tmpfiles, ... }:
let
inherit (nixpkgs) lib;
makePkgs = system: import nixpkgs { inherit system; };
forAllSystems = lib.genAttrs lib.systems.flakeExposed;
configBase = ./configurations;
makeSystem = name: module:
self.lib.nixbsdSystem {
modules = [ module { networking.hostName = "nixbsd-${name}"; } ];
};
makeImage = buildPlatform: conf:
let
extended = conf.extendModules {
modules = [{ config.nixpkgs.buildPlatform = buildPlatform; }];
};
in extended.config.system.build // {
# appease `nix flake show`
type = "derivation";
name = "system-build";
closureInfo = extended.pkgs.closureInfo {
rootPaths = [ extended.config.system.build.toplevel.drvPath ];
};
vmClosureInfo = extended.pkgs.closureInfo {
rootPaths = [ extended.config.system.build.vm.drvPath ];
};
inherit (extended) pkgs;
};
in {
lib.nixbsdSystem = args:
import ./lib/eval-config.nix (args // {
inherit (nixpkgs) lib;
nixpkgsPath = nixpkgs.outPath;
specialArgs = {
lixFlake = lix;
mini-tmpfiles-flake = mini-tmpfiles;
} // (args.specialArgs or { });
} // lib.optionalAttrs (!args ? system) { system = null; });
nixosConfigurations =
lib.mapAttrs (name: _: makeSystem name (configBase + "/${name}"))
(builtins.readDir configBase);
packages = forAllSystems (system:
lib.mapAttrs (name: makeImage system) self.nixosConfigurations);
formatter = forAllSystems (system: (makePkgs system).nixfmt-classic);
hydraJobs = lib.mapAttrs (system: lib.mapAttrs (configuration: attrs: {inherit (attrs) vm systemImage;})) self.packages;
};
}