abstract away architectures
This commit is contained in:
parent
2dee155b68
commit
57eee399e3
8 changed files with 69 additions and 36 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# dotfiles
|
# dotfiles
|
||||||
|
|
||||||
nix flake config! this is just used on my personal computer
|
nix flake config! this is just used on my personal computer(s)
|
||||||
|
|
||||||
## users
|
## users
|
||||||
|
|
||||||
|
|
@ -13,4 +13,5 @@ for something more server oriented, check out [`nix-server`](https://git.reidlab
|
||||||
each host should have these files:
|
each host should have these files:
|
||||||
|
|
||||||
- `default.nix`, contains everything relating to the basic system
|
- `default.nix`, contains everything relating to the basic system
|
||||||
- `hardware.nix`, hardware configuration.
|
- `hardware.nix`, hardware-specific configuration
|
||||||
|
- `meta.nix`, extra things passed thru to `mkHost`
|
||||||
|
|
|
||||||
16
flake.lock
generated
16
flake.lock
generated
|
|
@ -564,6 +564,7 @@
|
||||||
"nix-index-database": "nix-index-database",
|
"nix-index-database": "nix-index-database",
|
||||||
"nixpkgs": "nixpkgs_4",
|
"nixpkgs": "nixpkgs_4",
|
||||||
"rofi-catppuccin": "rofi-catppuccin",
|
"rofi-catppuccin": "rofi-catppuccin",
|
||||||
|
"systems": "systems_3",
|
||||||
"waybar-catppuccin": "waybar-catppuccin"
|
"waybar-catppuccin": "waybar-catppuccin"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -597,6 +598,21 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"systems_3": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1689347949,
|
||||||
|
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default-linux",
|
||||||
|
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default-linux",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"waybar-catppuccin": {
|
"waybar-catppuccin": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
|
|
||||||
43
flake.nix
43
flake.nix
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
systems.url = "github:nix-systems/default-linux";
|
||||||
|
|
||||||
home-manager.url = "github:nix-community/home-manager";
|
home-manager.url = "github:nix-community/home-manager";
|
||||||
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
@ -29,44 +30,50 @@
|
||||||
rofi-catppuccin.flake = false;
|
rofi-catppuccin.flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs @ { self, nixpkgs, ... }:
|
outputs = inputs @ { self, nixpkgs, systems, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib.my) mapModules mapModulesRec mapHosts;
|
inherit (lib.my) mapModules mapModulesRec mapHosts;
|
||||||
system = "x86_64-linux";
|
eachSystem = nixpkgs.lib.genAttrs (import systems);
|
||||||
|
|
||||||
mkPkgs = pkgs: extraOverlays:
|
lib = nixpkgs.lib.extend (final: prev: {
|
||||||
|
my = import ./lib {
|
||||||
|
inherit inputs;
|
||||||
|
lib = final;
|
||||||
|
pkgs = null;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
mkPkgs = system: pkgs: extraOverlays:
|
||||||
import pkgs {
|
import pkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
config.allowUnfree = true;
|
config.allowUnfree = true;
|
||||||
config.allowAliases = true;
|
config.allowAliases = true;
|
||||||
overlays = extraOverlays ++ (lib.attrValues self.overlays);
|
overlays = extraOverlays ++ (lib.attrValues self.overlays);
|
||||||
};
|
};
|
||||||
pkgs = mkPkgs nixpkgs [
|
|
||||||
|
pkgsFor = eachSystem (system:
|
||||||
|
mkPkgs system nixpkgs [
|
||||||
self.overlays.default
|
self.overlays.default
|
||||||
inputs.niri.overlays.niri
|
inputs.niri.overlays.niri
|
||||||
];
|
]
|
||||||
|
);
|
||||||
lib = nixpkgs.lib.extend (final: prev: {
|
|
||||||
my = import ./lib {
|
|
||||||
inherit pkgs inputs;
|
|
||||||
lib = final;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
in {
|
in {
|
||||||
lib = lib.my;
|
lib = lib.my;
|
||||||
|
|
||||||
overlays =
|
overlays = (mapModules ./overlays import) // {
|
||||||
(mapModules ./overlays import)
|
|
||||||
// {
|
|
||||||
default = final: prev: {
|
default = final: prev: {
|
||||||
my = self.packages.${system};
|
my = self.packages.${final.stdenv.hostPlatform.system};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
packages."${system}" = mapModules ./packages (p: pkgs.callPackage p {});
|
packages = eachSystem (system: let
|
||||||
|
pkgs = pkgsFor.${system};
|
||||||
|
in
|
||||||
|
mapModules ./packages (p: pkgs.callPackage p {})
|
||||||
|
);
|
||||||
|
|
||||||
nixosModules = mapModulesRec ./modules import;
|
nixosModules = mapModulesRec ./modules import;
|
||||||
|
|
||||||
nixosConfigurations = mapHosts ./hosts {};
|
nixosConfigurations = mapHosts ./hosts { inherit pkgsFor; };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,5 @@
|
||||||
# networking.interfaces.end0.useDHCP = lib.mkDefault true;
|
# networking.interfaces.end0.useDHCP = lib.mkDefault true;
|
||||||
# networking.interfaces.wlan0.useDHCP = lib.mkDefault true;
|
# networking.interfaces.wlan0.useDHCP = lib.mkDefault true;
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
|
||||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
hosts/goopnet-interface/meta.nix
Normal file
3
hosts/goopnet-interface/meta.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
system = "x86_64-linux";
|
||||||
|
}
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
in rec {
|
in rec {
|
||||||
# attrsToList
|
# attrsToList
|
||||||
attrsToList = attrs:
|
attrsToList = attrs:
|
||||||
mapAttrsToList (name: value: {inherit name value;}) attrs;
|
mapAttrsToList (name: value: { inherit name value; }) attrs;
|
||||||
|
|
||||||
# mapFilterAttrs ::
|
# mapFilterAttrs ::
|
||||||
# (name -> value -> bool)
|
# (name -> value -> bool)
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,42 @@
|
||||||
{
|
{
|
||||||
inputs,
|
inputs,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
|
||||||
self,
|
self,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (inputs.nixpkgs.lib) nixosSystem;
|
inherit (inputs.nixpkgs.lib) nixosSystem;
|
||||||
inherit (builtins) baseNameOf elem;
|
|
||||||
inherit (lib.attrsets) filterAttrs;
|
|
||||||
inherit (lib.modules) mkDefault;
|
inherit (lib.modules) mkDefault;
|
||||||
inherit (lib.strings) removeSuffix;
|
inherit (lib.strings) removeSuffix;
|
||||||
inherit (self.modules) mapModules;
|
inherit (self.modules) mapModules;
|
||||||
in rec {
|
in rec {
|
||||||
mkHost = path: attrs @ {system ? "x86_64-linux", ...}:
|
mkHost = path: {
|
||||||
|
system,
|
||||||
|
pkgsFor,
|
||||||
|
...
|
||||||
|
}:
|
||||||
nixosSystem {
|
nixosSystem {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
|
||||||
specialArgs = {inherit lib inputs system;};
|
specialArgs = { inherit lib inputs system; };
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
{
|
{
|
||||||
nixpkgs.pkgs = pkgs;
|
nixpkgs.pkgs = pkgsFor.${system};
|
||||||
|
nixpkgs.hostPlatform = lib.mkDefault system;
|
||||||
networking.hostName =
|
networking.hostName =
|
||||||
mkDefault (removeSuffix ".nix" (baseNameOf path));
|
mkDefault (removeSuffix ".nix" (baseNameOf path));
|
||||||
}
|
}
|
||||||
(filterAttrs (n: v: !elem n ["system"]) attrs)
|
|
||||||
../. # /default.nix
|
../. # /default.nix
|
||||||
(import path)
|
(import path)
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
mapHosts = dir: attrs @ {system ? system, ...}:
|
mapHosts = dir: attrs:
|
||||||
mapModules dir (hostPath: mkHost hostPath attrs);
|
mapModules dir (hostPath:
|
||||||
|
let
|
||||||
|
metaPath = "${hostPath}/meta.nix";
|
||||||
|
meta = import metaPath;
|
||||||
|
in
|
||||||
|
mkHost hostPath (attrs // meta)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.options) mkOption;
|
||||||
in {
|
in {
|
||||||
mkOpt = type: default: mkOption {inherit type default;};
|
mkOpt = type: default: mkOption { inherit type default; };
|
||||||
|
|
||||||
mkOpt' = type: default: description: mkOption {inherit type default description;};
|
mkOpt' = type: default: description: mkOption { inherit type default description; };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue