start switching to mkSystem

main
Carsten Kragelund 2023-06-26 14:42:29 +02:00
parent 520f23a088
commit cbcf9abd16
6 changed files with 249 additions and 152 deletions

@ -53,7 +53,7 @@
"inputs": { "inputs": {
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils_2",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs-unstable"
], ],
"nixpkgs-stable": "nixpkgs-stable" "nixpkgs-stable": "nixpkgs-stable"
}, },
@ -213,7 +213,7 @@
"inputs": { "inputs": {
"crane": "crane_2", "crane": "crane_2",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs-unstable"
], ],
"wezterm-src": "wezterm-src" "wezterm-src": "wezterm-src"
}, },
@ -275,16 +275,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1686828063, "lastModified": 1687729501,
"narHash": "sha256-Cv0Sx1N5+3xBDF5OnmFU3Qoh9OqZmXDBKg1fgXlXTWs=", "narHash": "sha256-mTLkMePoHUWvTCf3NuKbeYEea/tsikSIKBWwb9OfRr4=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "683f2f5ba2ea54abb633d0b17bc9f7f6dede5799", "rev": "35130d4b4f0b8c50ed2aceb909a538c66c91d4a0",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "id": "nixpkgs",
"ref": "nixpkgs-unstable", "ref": "nixos-23.05",
"type": "indirect" "type": "indirect"
} }
}, },
@ -304,6 +304,21 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-unstable": {
"locked": {
"lastModified": 1687701825,
"narHash": "sha256-aMC9hqsf+4tJL7aJWSdEUurW2TsjxtDcJBwM9Y4FIYM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "07059ee2fa34f1598758839b9af87eae7f7ae6ea",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixpkgs-unstable",
"type": "indirect"
}
},
"nur": { "nur": {
"locked": { "locked": {
"lastModified": 1686892756, "lastModified": 1686892756,
@ -328,6 +343,7 @@
"nix-darwin": "nix-darwin", "nix-darwin": "nix-darwin",
"nixos-wsl": "nixos-wsl", "nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable",
"nur": "nur", "nur": "nur",
"sanctureplicum-nur": "sanctureplicum-nur", "sanctureplicum-nur": "sanctureplicum-nur",
"sops-nix": "sops-nix" "sops-nix": "sops-nix"
@ -388,7 +404,7 @@
"sanctureplicum-nur": { "sanctureplicum-nur": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs-unstable"
] ]
}, },
"locked": { "locked": {
@ -408,7 +424,7 @@
"sops-nix": { "sops-nix": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs-unstable"
], ],
"nixpkgs-stable": [ "nixpkgs-stable": [
"nixpkgs" "nixpkgs"

@ -1,14 +1,15 @@
{ {
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable"; nixpkgs.url = "nixpkgs/nixos-23.05";
nixpkgs-unstable.url = "nixpkgs/nixpkgs-unstable";
nur.url = "github:nix-community/nur"; nur.url = "github:nix-community/nur";
sanctureplicum-nur = { sanctureplicum-nur = {
url = "git+https://gitea.pid1.sh/sanctureplicum/nur"; url = "git+https://gitea.pid1.sh/sanctureplicum/nur";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs-unstable";
}; };
nekowinston-nur = { nekowinston-nur = {
url = "github:nekowinston/nur"; url = "github:nekowinston/nur";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs-unstable";
}; };
home-manager = { home-manager = {
url = "github:nix-community/home-manager/release-23.05"; url = "github:nix-community/home-manager/release-23.05";
@ -17,7 +18,7 @@
sops-nix = { sops-nix = {
url = "github:Mic92/sops-nix"; url = "github:Mic92/sops-nix";
inputs = { inputs = {
nixpkgs.follows = "nixpkgs"; nixpkgs.follows = "nixpkgs-unstable";
nixpkgs-stable.follows = "nixpkgs"; nixpkgs-stable.follows = "nixpkgs";
}; };
}; };
@ -35,13 +36,14 @@
}; };
emacs-overlay = { emacs-overlay = {
url = "github:nix-community/emacs-overlay"; url = "github:nix-community/emacs-overlay";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs-unstable";
}; };
}; };
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
nixpkgs-unstable,
nur, nur,
sanctureplicum-nur, sanctureplicum-nur,
nekowinston-nur, nekowinston-nur,
@ -55,12 +57,12 @@
} @ inputs: let } @ inputs: let
overlays = [ overlays = [
(import emacs-overlay) (import emacs-overlay)
(final: prev: (final: prev: let
# let unstable = import nixpkgs-unstable { unstable = import nixpkgs-unstable {
# system = prev.system; system = prev.system;
# config.allowUnfree = true; config.allowUnfree = true;
# }; in };
{ in {
nur = import nur { nur = import nur {
nurpkgs = prev; nurpkgs = prev;
pkgs = prev; pkgs = prev;
@ -72,117 +74,171 @@
}; };
}; };
}; };
#inherit unstable; inherit unstable;
}) })
]; ];
in { overlayModule = {
nixosConfigurations.falcon = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({
config, config,
pkgs, pkgs,
... ...
}: { }: {
nixpkgs.overlays = overlays; nixpkgs.overlays = overlays;
}) };
hmConfig = sops: [
home-manager.nixosModules.home-manager
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.backupFileExtension = "bak"; home-manager.backupFileExtension = "bak";
home-manager.sharedModules =
if sops
then [
sops-nix.homeManagerModule
]
else [];
home-manager.extraSpecialArgs = {inherit inputs;};
} }
./users/carsten
];
mkSystem = {
host,
system,
hm ? true,
wsl ? false,
sops ? false,
sops-hm ? false,
modules ? [],
}: let
isDarwin = builtins.match ".+?-linux" == null;
builder =
if isDarwin
then nix-darwin.lib.darwinSystem
else nixpkgs.lib.nixosSystem;
hmModule =
if isDarwin
then home-manager.darwinModules.home-manager
else home-manager.nixosModules.home-manager;
sopsModule =
if isDarwin
then sops-nix.darwinModules.sops
else sops-nix.nixosModules.sops;
systemModule =
if isDarwin
then ./hosts/common/darwin.nix
else ./hosts/common/linux.nix;
in
builder {
inherit system;
specialArgs = {
inherit inputs;
};
modules =
[
overlayModule
(./hosts + "/${host}")
systemModule
]
++ (
if hm
then [hmModule] ++ (hmConfig sops-hm)
else []
)
++ (
if wsl
then [nixos-wsl.nixosModules.wsl]
else []
)
++ (
if sops
then [sopsModule]
else []
)
++ modules;
};
in {
nixosConfigurations.falcon = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit inputs;
};
modules =
[
overlayModule
home-manager.nixosModules.home-manager
./hosts/falcon ./hosts/falcon
./hosts/common/linux.nix ./hosts/common/linux.nix
]; ]
++ hmConfig;
}; };
nixosConfigurations.eagle = nixpkgs.lib.nixosSystem { nixosConfigurations.eagle = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ specialArgs = {
({ inherit inputs;
config, };
pkgs, modules =
... [
}: { overlayModule
nixpkgs.overlays = overlays;
})
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "bak";
home-manager.sharedModules = [ home-manager.sharedModules = [
sops-nix.homeManagerModule sops-nix.homeManagerModule
]; ];
} }
./hosts/eagle ./hosts/eagle
./hosts/common/linux.nix ./hosts/common/linux.nix
]; ]
++ hmConfig;
}; };
darwinConfigurations.hawk = nix-darwin.lib.darwinSystem { darwinConfigurations.hawk = nix-darwin.lib.darwinSystem {
system = "aarch64-darwin"; system = "aarch64-darwin";
modules = [ specialArgs = {
({ inherit inputs;
config, };
pkgs, modules =
... [
}: { overlayModule
nixpkgs.overlays = overlays;
})
home-manager.darwinModules.home-manager home-manager.darwinModules.home-manager
{ {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "bak";
home-manager.sharedModules = [ home-manager.sharedModules = [
sops-nix.homeManagerModule sops-nix.homeManagerModule
]; ];
} }
./hosts/hawk ./hosts/hawk
./hosts/common/darwin.nix ./hosts/common/darwin.nix
]; ]
++ hmConfig;
}; };
nixosConfigurations.buzzard = nixpkgs.lib.nixosSystem { nixosConfigurations.buzzard = mkSystem {
host = "buzzard";
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ wsl = true;
({ };
config, # nixpkgs.lib.nixosSystem {
pkgs, # system = "x86_64-linux";
... # specialArgs = {
}: { # inherit inputs;
nixpkgs.overlays = overlays; # };
}) # modules =
# [
# overlayModule
nixos-wsl.nixosModules.wsl # nixos-wsl.nixosModules.wsl
home-manager.nixosModules.home-manager # home-manager.nixosModules.home-manager
{ # ./hosts/buzzard
home-manager.useGlobalPkgs = true; # ./hosts/common/linux.nix
home-manager.useUserPackages = true; # ]
home-manager.backupFileExtension = "bak"; # ++ hmConfig;
home-manager.sharedModules = [ # };
(import ./powershell.nix)
];
}
./hosts/buzzard
./hosts/common/linux.nix
];
};
nixosConfigurations.gitea = nixpkgs.lib.nixosSystem { nixosConfigurations.gitea = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = {craneLib = crane.lib."x86_64-linux";}; specialArgs = {
inherit inputs;
craneLib = crane.lib."x86_64-linux";
};
modules = [ modules = [
({ overlayModule
config,
pkgs,
...
}: {
nixpkgs.overlays = overlays;
})
sops-nix.nixosModules.sops sops-nix.nixosModules.sops
./hosts/gitea ./hosts/gitea
./hosts/common/linux.nix ./hosts/common/linux.nix

@ -1,7 +1,8 @@
{ config {
, modulesPath config,
, pkgs modulesPath,
, ... pkgs,
...
}: { }: {
imports = [ imports = [
./hardware.nix ./hardware.nix
@ -12,13 +13,19 @@
wsl = { wsl = {
enable = true; enable = true;
wslConf.automount.root = "/mnt";
defaultUser = "carsten"; defaultUser = "carsten";
startMenuLaunchers = true; wslConf = {
automount.enabled = false;
interop = {
enabled = false;
appendWindowsPath = false;
};
};
interop.includePath = false;
}; };
services.openssh = { services.openssh = {
enable = true; enable = true;
permitRootLogin = "yes"; settings.PermitRootLogin = "yes";
}; };
graphical = false; graphical = false;
nix.settings.build-cores = 12; nix.settings.build-cores = 12;

@ -1,25 +1,32 @@
{ config, lib, ... }: { {
pkgs,
config,
lib,
...
}: {
imports = [ imports = [
./graphical.nix ./graphical.nix
./vm-guest.nix ./vm-guest.nix
]; ];
users = { users = {
defaultUserShell = bash; defaultUserShell = pkgs.bash;
mutableUsers = true; mutableUsers = true;
users.root = { users.root = {
home = "/root"; home = "/root";
uid = ids.uids.root; uid = config.ids.uids.root;
group = "root"; group = "root";
initialHashedPassword = mkDefault "!"; initialHashedPassword = lib.mkDefault "!";
}; };
}; };
# Configure console keymap # Configure console keymap
console.keyMap = "us"; console.keyMap = "us";
boot = lib.mkIf (!config.wsl.enable or false) { boot =
networking.nameservers = [ "192.168.1.1" "87.62.97.64" ]; if (!config.wsl.enable or false)
then {
networking.nameservers = ["192.168.1.1" "87.62.97.64"];
loader = { loader = {
systemd-boot = { systemd-boot = {
@ -31,7 +38,8 @@
efiSysMountPoint = "/boot/efi"; efiSysMountPoint = "/boot/efi";
}; };
}; };
}; }
else {};
# Select internationalisation properties. # Select internationalisation properties.
i18n.defaultLocale = "en_US.utf8"; i18n.defaultLocale = "en_US.utf8";
i18n.extraLocaleSettings = { i18n.extraLocaleSettings = {

@ -5,10 +5,29 @@
... ...
}: { }: {
imports = []; imports = [];
users.users.carten = { users.users.carten =
home = if lib.traceVal pkgs.stdenv.isLinux then "/home/carsten" else lib.traceVal "/Users/carsten"; {
}; home =
if pkgs.stdenv.isLinux
then "/home/carsten"
else "/Users/carsten";
}
// (
if pkgs.stdenv.isLinux
then {
isNormalUser = true;
description = "Carsten Kragelund";
hashedPassword = "$y$j9T$oL/jNqI1yz65OuUnJvpCn1$MC7.xSyvprru7QmqQVsGyBKZf2b4w7R7U.TmfzSBY39";
shell = pkgs.bash;
extraGroups = [
"networkmanager" # Use networks
"wheel" # Sudoer
"vboxusers" # VirtualBox
"docker" # Containers
];
}
else {}
);
home-manager.users.carsten = { home-manager.users.carsten = {
imports = [ imports = [
@ -16,9 +35,12 @@
]; ];
home = { home = {
stateVersion = builtins.trace config.users.users.carsten.home "23.05"; stateVersion = "23.05";
homeDirectory = if pkgs.stdenv.isLinux then "/home/carsten" else lib.mkForce "/Users/carsten"; homeDirectory =
if pkgs.stdenv.isLinux
then "/home/carsten"
else "/Users/carsten";
username = "carsten"; username = "carsten";
}; };
}; };

@ -1,12 +0,0 @@
{ ... }: {
carsten = {
fullName = "Carsten Kragelund";
hashedPassword = "$y$j9T$oL/jNqI1yz65OuUnJvpCn1$MC7.xSyvprru7QmqQVsGyBKZf2b4w7R7U.TmfzSBY39";
groups = [
"networkmanager" # Use networks
"wheel" # Sudoer
"vboxusers" # VirtualBox
"docker" # Containers
];
}
}