-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
119 lines (109 loc) · 3.98 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
109
110
111
112
113
114
115
116
117
118
119
{
description = "Home Manager";
inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
attic.url = "github:zhaofengli/attic";
flake-utils.url = "github:numtide/flake-utils";
devshell.url = "github:numtide/devshell";
};
outputs = { self, nixpkgs, flake-utils, devshell, home-manager, attic }:
(flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
devshell.overlays.default
attic.overlays.default
];
};
# list all profiles
profiles = [ "testuser" ] ++ (
builtins.filter
(x: x != null)
(
builtins.map
(name: if builtins.pathExists ./profiles/${name}/default.nix then name else null)
(builtins.attrNames (builtins.readDir ./profiles))
)
);
activationPackages = builtins.map (x: (self.lib.mkHomeManagerConfiguration system x).activationPackage) profiles;
allProfiles = pkgs.runCommandNoCC "all-profiles"
{
activationPackages = activationPackages;
}
''
mkdir -p $out
for profile in $activationPackages; do
ln -s $profile $out/
done
'';
in
{
# Ensure we can build Home Manager activation package
checks = {
allProfiles = self.packages.${system}.allProfiles;
installer = self.packages.${system}.default;
};
# Expose the installer
packages = {
default = pkgs.callPackage ./installer/command.nix { inherit self home-manager; };
allProfiles = allProfiles;
};
devShells.default = pkgs.devshell.mkShell ({ config, ... }: {
commands = [
{
help = "Push release artifacts to our public attic cache";
name = "do-push-release";
command = ''
${pkgs.attic-client}/bin/attic push alpha:release-public \
$(nix build .#packages.x86_64-linux.allProfiles --no-link --print-out-paths) \
$(nix build .#packages.aarch64-linux.allProfiles --no-link --print-out-paths) \
$(nix build .#packages.x86_64-linux.default --no-link --print-out-paths) \
$(nix build .#packages.aarch64-linux.default --no-link --print-out-paths)
'';
}
];
});
}))
// {
# Expose the Home Manager configuration builder
lib.mkHomeManagerConfiguration = system: username:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
attic.overlays.default
];
config.allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [
"vault"
];
};
in
home-manager.lib.homeManagerConfiguration {
inherit pkgs;
# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [
# User specific setup
{
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = username;
home.homeDirectory = "/home/${username}";
}
./modules/home.nix
./modules/nix/basics.nix
./modules/nix/auto-login.nix
./modules/nix/watch-cache.nix
./modules/git/auto-setup-profile.nix
] ++ (if builtins.pathExists ./profiles/${username}/default.nix then [ ./profiles/${username}/default.nix ] else [ ]);
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
};
};
}