-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
108 lines (93 loc) · 3.08 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
{
description = "An application to assist in installing NixOS on ZFS.";
nixConfig.bash-prompt-prefix = "\[nix-develop\] ";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.flake-compat.url = "github:edolstra/flake-compat";
inputs.flake-compat.flake = false;
inputs.nixos-generators.url = "github:nix-community/nixos-generators";
inputs.nixos-generators.inputs.nixpkgs.follows = "nixpkgs";
inputs.poetry2nix.url = "github:nix-community/poetry2nix";
inputs.poetry2nix.inputs.flake-utils.follows = "flake-utils";
inputs.poetry2nix.inputs.nixpkgs.follows = "nixpkgs";
inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
inputs.pre-commit-hooks.inputs.flake-utils.follows = "flake-utils";
inputs.pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
outputs = {
self,
nixpkgs,
flake-utils,
flake-compat,
nixos-generators,
poetry2nix,
pre-commit-hooks,
}:
flake-utils.lib.eachSystem [flake-utils.lib.system.x86_64-linux] (
system: let
overlays = [
poetry2nix.overlay
];
pkgs = import nixpkgs {
inherit overlays system;
};
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = self;
hooks = {
alejandra.enable = true;
black.enable = true;
isort.enable = true;
};
};
python = pkgs.python310;
pybootstrapSet = {
inherit python;
projectDir = self + /pybootstrap;
};
pybootstrapEnv = pkgs.poetry2nix.mkPoetryEnv (
pybootstrapSet
// {
editablePackageSources = {
pybootstrap = pybootstrapSet.projectDir;
};
}
);
pybootstrapApp = pkgs.poetry2nix.mkPoetryApplication pybootstrapSet;
# Uses nixos-generators to generate output for the given target format.
mkGenerate = format: {
"image-${format}" = nixos-generators.nixosGenerate {
inherit format system;
modules = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
({...}: {
environment.systemPackages = [
pybootstrapApp
];
nix.settings.experimental-features = "nix-command flakes";
})
];
};
};
in {
packages =
{
inherit pybootstrapApp pybootstrapEnv;
default = pybootstrapApp;
}
// mkGenerate "iso"
// mkGenerate "vm"
// {}; # nix formatter hack
apps.default.program = "${pybootstrapApp}/bin/pybootstrap";
apps.default.type = "app";
devShells.default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
packages = with pkgs; [
pybootstrapEnv
python310Packages.poetry
];
};
checks = {
inherit pre-commit-check;
};
}
);
}