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

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

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

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

@ -5,10 +5,29 @@
...
}: {
imports = [];
users.users.carten = {
home = if lib.traceVal pkgs.stdenv.isLinux then "/home/carsten" else lib.traceVal "/Users/carsten";
};
users.users.carten =
{
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 = {
imports = [
@ -16,9 +35,12 @@
];
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";
};
};

@ -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
];
}
}