-
Notifications
You must be signed in to change notification settings - Fork 21
/
flake.nix
78 lines (62 loc) · 1.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
{
description = "LibVirt domain management";
inputs =
{
nixpkgs =
{
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "nixos-24.05";
};
};
outputs = { self, nixpkgs }:
let
packages = import nixpkgs { system = "x86_64-linux"; };
nixvirtPythonModulePackage = packages.runCommand "nixvirtPythonModulePackage" { }
''
mkdir -p $out/lib/python3.11/site-packages/
ln -s ${tool/nixvirt.py} $out/lib/python3.11/site-packages/nixvirt.py
'' // { pythonModule = packages.python311; };
pythonInterpreterPackage = packages.python311.withPackages (ps:
[
ps.libvirt
ps.lxml
ps.xmldiff
nixvirtPythonModulePackage
]);
setShebang = name: path: packages.runCommand name { }
''
sed -e "1s|.*|\#\!${pythonInterpreterPackage}/bin/python3|" ${path} > $out
chmod 755 $out
'';
virtdeclareFile = setShebang "virtdeclare" tool/virtdeclare;
moduleHelperFile = setShebang "nixvirt-module-helper" tool/nixvirt-module-helper;
mklib = import ./lib.nix;
modules = import ./modules.nix { inherit packages moduleHelperFile; };
stuff = { inherit packages; };
in
{
lib = mklib stuff;
apps.x86_64-linux.virtdeclare =
{
type = "app";
program = "${virtdeclareFile}";
};
# for debugging
apps.x86_64-linux.nixvirt-module-helper =
{
type = "app";
program = "${moduleHelperFile}";
};
formatter.x86_64-linux = packages.nixpkgs-fmt;
packages.x86_64-linux.default = packages.runCommand "NixVirt" { }
''
mkdir -p $out/bin
ln -s ${virtdeclareFile} $out/bin/virtdeclare
'';
homeModules.default = modules.homeModule;
nixosModules.default = modules.nixosModule;
checks.x86_64-linux = import checks/checks.nix stuff mklib;
};
}