-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathflake.nix
104 lines (76 loc) · 2.99 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
{
description = "A filesystem that fetches DWARF debug info from the Internet on demand";
inputs.nix.url = "https://flakehub.com/f/NixOS/nix/2.25.tar.gz";
inputs.nixpkgs.follows = "nix/nixpkgs";
outputs = { self, nix, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
version = "0.1.${nixpkgs.lib.substring 0 8 self.lastModifiedDate}.${self.shortRev or "dirty"}";
in
{
overlays.default = final: prev: {
dwarffs = with final; let nix = final.nix; in stdenv.mkDerivation {
pname = "dwarffs";
inherit version;
buildInputs = [ fuse nix nlohmann_json boost ];
NIX_CFLAGS_COMPILE = "-I ${nix.dev}/include/nix -include ${nix.dev}/include/nix/config.h -D_FILE_OFFSET_BITS=64 -DVERSION=\"${version}\"";
src = self;
installPhase =
''
mkdir -p $out/bin $out/lib/systemd/system
cp dwarffs $out/bin/
ln -s dwarffs $out/bin/mount.fuse.dwarffs
cp ${./run-dwarffs.mount} $out/lib/systemd/system/run-dwarffs.mount
cp ${./run-dwarffs.automount} $out/lib/systemd/system/run-dwarffs.automount
'';
};
};
packages = forAllSystems (system: {
default = (import nixpkgs {
inherit system;
overlays = [ self.overlays.default nix.overlays.default ];
}).dwarffs;
});
checks = forAllSystems (system: {
build = self.packages.${system}.default;
test =
with import (nixpkgs + "/nixos/lib/testing-python.nix") {
inherit system;
};
makeTest {
name = "dwarffs";
nodes = {
client = { ... }: {
imports = [ self.nixosModules.dwarffs ];
nixpkgs.overlays = [ nix.overlays.default ];
};
};
testScript =
''
start_all()
client.wait_for_unit("multi-user.target")
client.succeed("dwarffs --version")
client.succeed("cat /run/dwarffs/README")
client.succeed("[ -e /run/dwarffs/.build-id/00 ]")
'';
};
});
nixosModules.dwarffs =
{ pkgs, ... }:
{
nixpkgs.overlays = [ self.overlays.default ];
systemd.packages = [ pkgs.dwarffs ];
system.fsPackages = [ pkgs.dwarffs ];
systemd.units."run-dwarffs.automount".wantedBy = [ "multi-user.target" ];
environment.variables.NIX_DEBUG_INFO_DIRS = [ "/run/dwarffs" ];
systemd.tmpfiles.rules = [ "d /var/cache/dwarffs 0755 dwarffs dwarffs 7d" ];
users.users.dwarffs =
{ description = "Debug symbols file system daemon user";
group = "dwarffs";
isSystemUser = true;
};
users.groups.dwarffs = {};
};
};
}