This repository has been archived by the owner on Apr 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
145 lines (132 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
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
{
description = "nixnad";
inputs =
{
home-manager = {
url = "github:nix-community/home-manager/release-21.11";
inputs.nixpkgs.follows = "nixpkgs";
};
unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11";
nixpkgs-master.url = "github:NixOS/nixpkgs/master";
nixpkgs-latest.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# my personal neovim
copper.url = "github:zoedsoupe/copper";
emacs = {
url = "github:nix-community/emacs-overlay";
inputs.nixpkgs.follows = "master";
};
# my personal emacs
aqua = {
url = "github:zoedsoupe/aqua";
flake = false;
};
};
outputs = { self, ... }@inputs:
let
inherit (inputs)
nixpkgs
nixpkgs-latest
home-manager
unstable
copper
;
inherit (pkgs.lib) nixosSystem;
inherit (builtins) toString trace;
inherit (home-manager.lib) homeManagerConfiguration;
pkgs = import nixpkgs {
inherit overlays;
inherit (global) system;
config = {
allowUnfree = true;
};
};
epkgs = import nixpkgs {
inherit (global) system;
overlays = [ self.overlays.emacs ];
};
global = rec {
username = "zoedsoupe";
email = "[email protected]";
selected-desktop-environment = "gnome";
rootPath = builtins.toString ./.;
rooPathNix = rootPath;
environmentShell = ''
export NIXPKGS_ALLOW_UNFREE=1
export NIXNAD_ROOT_PATH=/home/$USER/documents/privy/nixnad
export NIX_PATH=nixpkgs=${nixpkgs}:nixpkgs-overlays=$NIXNAD_ROOT_PATH/compat/overlay.nix:nixpkgsLatest=${nixpkgs-latest}:home-manager=${home-manager}:nixos-config=$NIXNAD_ROOT_PATH/nodes/$HOSTNAME/default.nix
'';
system = "x86_64-linux";
};
extra-args = {
inherit self;
inherit global;
cfg = throw "your past self made a trap for non compliant code after a migration you did, now follow the stacktrace and go fix it";
};
overlays = [
(import ./overlay.nix self)
(import "${home-manager}/overlay.nix")
];
hm-config = config:
let
source = config // {
extraSpecialArgs = extra-args;
inherit pkgs;
};
evaluated = homeManagerConfiguration source;
in evaluated // { inherit source; };
nixos-config = {main-module, extra-modules ? []}:
let
rev-module = { pkgs, ... }: {
system.configurationRevision = if (self ? rev) then
trace "detected flake hash: ${self.rev}" self.rev
else
trace "flake hash not detected!" null;
};
source = {
inherit pkgs;
inherit (global) system;
modules = [ rev-module (main-module) ] ++ extra-modules;
specialArgs = extra-args;
};
eval = import "${nixpkgs}/nixos/lib/eval-config.nix";
override = my-source: fn: let
source-processed = my-source // (fn my-source);
evaluated = eval source-processed;
in evaluated // {
source = source-processed;
override = override source-processed;
};
in override source (v: {});
in {
inherit extra-args;
inherit (global) environment-shell;
packages."${global.system}" = {
emacs = epkgs.emacsUnstable;
};
homeConfigurations = {
main = hm-config {
configuration = import ./home/default.nix;
homeDirectory = "/home/${global.username}";
inherit (global) system username;
};
};
nixosConfigurations = {
acer-nix = nixos-config {
main-module = ./nodes/acer-nix;
};
bootstrap = nixos-config {
main-module = ./nodes/bootstrap;
};
};
dev-shell.x86_64-linux = pkgs.mkShell {
name = "nixnad-shell";
buildInputs = [];
shellHook = ''
${global.environment-shell}
echo '${global.environment-shell}'
echo Shell setup complete!
'';
};
};
}