-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
155 lines (129 loc) · 4.1 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
{
description = "A NixOS config with thousands stories";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
nixvim = {
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-colors.url = "github:misterio77/nix-colors";
hyprland.url = "github:hyprwm/Hyprland";
utils.url = "github:numtide/flake-utils";
vizier = {
url = "git+file:./modules/vizier";
flake = true;
};
};
outputs =
{ self
, nixpkgs
, home-manager
, utils
, systems
, ...
} @ inputs:
let
repo = "github:blinfoldking/monomyth";
username = builtins.getEnv "USER";
inherit (self) outputs;
in
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
packages = {
nixosConfigurations = {
nixos = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs username system; };
modules = [
./nixos/core.nix
];
};
};
homeConfigurations = {
"${username}@nixos" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = { inherit inputs outputs username; };
modules = [ ./home-manager/home.nix ];
};
};
};
devShells.default =
let
build-os = "sudo nixos-rebuild switch --impure --flake";
upgrade-os = "sudo nixos-rebuild --upgrade switch --impure --flake";
build-home = "home-manager build switch --impure --flake";
scripts = with pkgs; [
(writeScriptBin "helpme" ''
_usage="
make sure you check and adjust everything, then run
one of these commands
COMMAND USAGE
install to install/update the whole config
update-os to update os config
upgrade-os to upgrade os config
update-home to update home manager
logout logout user
reboot restart your system
list-generations list all generations
clean-os-generations remove old generations up to 5 recent one
PS: this shell include vim for you to make
simple edits
"
echo "$_usage"
'')
(writeScriptBin "install" ''
echo "install source: "$MODE
update-os && update-home
'')
(writeScriptBin "update-os" ''
if [[ "$MODE" == "github" ]];
then
${build-os} ${repo}
else
${build-os} .
fi
'')
(writeScriptBin "update-home" ''
if [[ "$MODE" == "github" ]];
then
${build-home} ${repo}#$USER@nixos
else
${build-home} .#$USER@nixos
fi
'')
(writeScriptBin "logout" ''
pkill -KILL -u $USER
'')
(writeScriptBin "upgrade-os" ''
if [[ "$MODE" == "github" ]];
then
${upgrade-os} ${repo}
else
${upgrade-os} .
fi
'')
(writeScriptBin "list-generations" ''
sudo nix-env --profile /nix/var/nix/profiles/system --list-generations
'')
(writeScriptBin "clean-os-generations" ''
sudo nix-env --profile /nix/var/nix/profiles/system --delete-generations +5
'')
];
in
pkgs.mkShell {
name = "monomyth-install";
packages = with pkgs; [
git
vim
just
] ++ scripts;
shellHook = ''
helpme
'';
};
});
}