-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
executable file
·74 lines (69 loc) · 1.55 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
{
description = "Global FHS environment for your daily computing needs.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
};
in {
devShells.default = let
script = pkgs.writeShellScriptBin "test-vm" ''
timeout() {
seq 1 5 | while read r; do
echo x
sleep 1
done | awk '
NR < 5 {
printf "\r(press CTRL-C to cancel) Starting vm in %d\033[0K", 6 - NR
}
NR > 4 {
printf "\rStarting vm in %d\033[0K", 6 - NR
}
END {
printf "\rStarting vm\033[0K\n"
}
'
}
run-vm() {
pushd test &>/dev/null
nix flake update -v --inputs-from ../ 2>&1 | awk '
{
printf "\rUpdating flake"
}
END {
printf "\rDone\033[0K\n"
}
'
nixos-shell --flake .#
popd &>/dev/null
}
test-vm() {
run-vm
timeout
test-vm
}
test-vm
'';
in pkgs.mkShell {
packages = with pkgs; [
nixos-shell
ncurses
script
gawk
jq
];
shellHook = ''
echo -e "\033[31mRun test-vm to test your code\033[0m"
'';
NIX_PATH="nixpkgs=${nixpkgs}";
};
}) // {
nixosModules = rec {
nixos-fhs = import ./module;
default = nixos-fhs;
};
};
}