forked from aldur/nixos-crostini
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
80 lines (69 loc) · 2.2 KB
/
flake.nix
File metadata and controls
80 lines (69 loc) · 2.2 KB
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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
nixos-generators,
nixpkgs,
self,
...
}@inputs:
let
modules = [ ./configuration.nix ];
# https://nixos-and-flakes.thiscute.world/nixos-with-flakes/nixos-flake-and-module-system
specialArgs = { inherit inputs; };
# https://ayats.org/blog/no-flake-utils
forAllSystems = nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
];
# NOTE: change to `x86_64-linux` if that is your architecture.
targetSystem = "aarch64-linux";
in
{
packages = forAllSystems (system: rec {
lxc = nixos-generators.nixosGenerate {
inherit system specialArgs;
modules = modules ++ [ self.nixosModules.crostini ];
format = "lxc";
};
lxc-metadata = nixos-generators.nixosGenerate {
inherit system specialArgs;
modules = modules ++ [ self.nixosModules.crostini ];
format = "lxc-metadata";
};
lxc-image-and-metadata = nixpkgs.legacyPackages.${system}.stdenv.mkDerivation {
name = "lxc-image-and-metadata";
dontUnpack = true;
installPhase = ''
mkdir -p $out
ln -s ${lxc-metadata}/tarball/*.tar.xz $out/metadata.tar.xz
ln -s ${lxc}/tarball/*.tar.xz $out/image.tar.xz
'';
};
default = self.packages.${system}.lxc-image-and-metadata;
});
checks = forAllSystems (system: {
inherit (self.outputs.packages.${system}) lxc-image-and-metadata;
});
# This allows you to re-build the container from inside the container.
nixosConfigurations.lxc-nixos = nixpkgs.lib.nixosSystem {
inherit specialArgs;
modules = modules ++ [ self.nixosModules.crostini ];
system = targetSystem;
};
nixosModules = rec {
crostini = ./crostini.nix;
default = crostini;
};
templates.default = {
path = self;
description = "nixos-crostini quick start";
};
};
}