-
-
Notifications
You must be signed in to change notification settings - Fork 219
/
Copy pathflake.nix
123 lines (114 loc) · 3.81 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
119
120
121
122
123
{
description = "Disko - declarative disk partitioning";
# FIXME: in future we don't want lock here to give precedence to a USB live-installer's registry,
# but garnix currently does not allow this.
#inputs.nixpkgs.url = "nixpkgs";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs =
{ self, nixpkgs, ... }:
let
lib = nixpkgs.lib;
supportedSystems = [
"x86_64-linux"
"i686-linux"
"aarch64-linux"
"riscv64-linux"
];
forAllSystems = lib.genAttrs supportedSystems;
versionInfo = import ./version.nix;
version = versionInfo.version + (lib.optionalString (!versionInfo.released) "-dirty");
diskoLib = import ./lib {
inherit (nixpkgs) lib;
};
in
{
nixosModules.default = self.nixosModules.disko; # convention
nixosModules.disko = ./module.nix;
lib = diskoLib;
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
disko = pkgs.callPackage ./package.nix { diskoVersion = version; };
# alias to make `nix run` more convenient
disko-install = self.packages.${system}.disko.overrideAttrs (_old: {
name = "disko-install";
});
default = self.packages.${system}.disko;
create-release = pkgs.callPackage ./scripts/create-release.nix { };
}
// pkgs.lib.optionalAttrs (!pkgs.stdenv.buildPlatform.isRiscV64) {
disko-doc = pkgs.callPackage ./doc.nix { };
}
);
# TODO: disable bios-related tests on aarch64...
# Run checks: nix flake check -L
checks = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
# FIXME: aarch64-linux seems to hang on boot
nixosTests = lib.optionalAttrs pkgs.stdenv.hostPlatform.isx86_64 (
import ./tests {
inherit pkgs;
makeTest = import (pkgs.path + "/nixos/tests/make-test-python.nix");
eval-config = import (pkgs.path + "/nixos/lib/eval-config.nix");
}
);
disko-install = pkgs.callPackage ./tests/disko-install {
inherit self;
diskoVersion = version;
};
jsonTypes = pkgs.writeTextFile {
name = "jsonTypes";
text = (builtins.toJSON diskoLib.jsonTypes);
};
treefmt = pkgs.runCommand "treefmt" { } ''
${self.formatter.${system}}/bin/treefmt --ci --working-dir ${self}
touch $out
'';
in
# FIXME: aarch64-linux seems to hang on boot
lib.optionalAttrs pkgs.stdenv.hostPlatform.isx86_64 (nixosTests // { inherit disko-install; })
//
pkgs.lib.optionalAttrs (!pkgs.stdenv.buildPlatform.isRiscV64 && !pkgs.stdenv.hostPlatform.isx86_32)
{
inherit jsonTypes treefmt;
inherit (self.packages.${system}) disko-doc;
}
);
nixosConfigurations.testmachine = lib.nixosSystem {
system = "x86_64-linux";
modules = [
./tests/disko-install/configuration.nix
./example/hybrid.nix
./module.nix
];
};
formatter = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
pkgs.writeShellApplication {
name = "treefmt";
text = ''treefmt "$@"'';
runtimeInputs = [
pkgs.deadnix
pkgs.nixfmt-rfc-style
pkgs.shellcheck
pkgs.treefmt
];
}
);
devShells = forAllSystems (system: {
default = nixpkgs.legacyPackages.${system}.mkShell {
packages = [
self.formatter.${system}
];
};
});
};
}