-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
103 lines (91 loc) · 2.47 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
{
description = "Nixos config flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
# nixvim should be declared here
nixvim = {
url = "github:nix-community/nixvim/nixos-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
home-manager,
nixvim,
...
} @ inputs: let
system = "x86_64-linux";
pkgs = import nixpkgs {inherit system;};
# detect the device for hardware specific stuff
# Fetch the machine-id from /etc/machine-id
machineId = builtins.replaceStrings ["\n"] [""] (builtins.readFile "/etc/machine-id");
# Determine the device based on the machine-id from /etc/machine-id
device = (
if machineId == "be2ddb959d5646dfb65446e0b9be05ed"
then
(
builtins.trace "Machine ID: ${machineId}, using desktop configuration"
"desktop"
)
else if machineId == "a8bdaefc14bf4f0aa5d96468ceb313d9"
then
(
builtins.trace "Machine ID: ${machineId}, using laptop configuration"
"laptop"
)
else abort "Unknown machine-id: ${machineId}"
);
hardwareConfig =
if device == "desktop"
then ./devices/desktop.nix
else ./devices/laptop.nix;
# import foundry related utilities
foundry-bin = import ./foundry-bin {inherit pkgs;};
in {
# setup foundry
apps = {
anvil = {
type = "app";
program = "${foundry-bin}/bin/anvil";
};
chisel = {
type = "app";
program = "${foundry-bin}/bin/chisel";
};
cast = {
type = "app";
program = "${foundry-bin}/bin/cast";
};
forge = {
type = "app";
program = "${foundry-bin}/bin/forge";
};
};
defaultPackage = foundry-bin;
devShell = pkgs.mkShell {
buildInputs = [
foundry-bin
];
};
overlay = final: prev: {
foundry-bin = final.callPackage ./foundry-bin {};
};
nixosConfigurations.default = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs device;};
modules = [
hardwareConfig
./configuration.nix
home-manager.nixosModules.default
{
environment.systemPackages = [foundry-bin];
home-manager.sharedModules = [nixvim.homeManagerModules.nixvim];
}
];
};
};
}