Compare commits

..

2 Commits

Author SHA1 Message Date
soraefir e5a75cb3b7 Multi system and pkgs cleanup 2026-06-20 12:50:42 +02:00
soraefir 8e21f3dae8 Cleanup 2026-06-20 10:54:17 +02:00
12 changed files with 84 additions and 148 deletions
+10 -51
View File
@@ -36,31 +36,16 @@
}; };
}; };
outputs = outputs = inputs:
inputs:
let let
lib = inputs.nixpkgs.lib; lib = inputs.nixpkgs.lib;
supportedSystems = [ linuxSystems = [ "x86_64-linux" "aarch64-linux" ];
"x86_64-linux" supportedSystems = linuxSystems ++ [ "x86_64-darwin" "aarch64-darwin" ];
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
linuxSystems = [
"x86_64-linux"
"aarch64-linux"
];
forEachSystem = lib.genAttrs;
overlays = import ./overlays { inherit inputs; }; overlays = import ./overlays { inherit inputs; };
mkPkgs = mkPkgs = system:
system:
import inputs.nixpkgs { import inputs.nixpkgs {
inherit system; inherit system;
overlays = overlays ++ [ inherit overlays;
(final: prev: {
custom = import ./packages { pkgs = final; };
})
];
config.allowUnfree = true; config.allowUnfree = true;
}; };
gen = import ./generator.nix { inherit inputs mkPkgs supportedSystems; }; gen = import ./generator.nix { inherit inputs mkPkgs supportedSystems; };
@@ -74,37 +59,11 @@
&& builtins.pathExists (systemsDir + "/${name}/cfg.nix") && builtins.pathExists (systemsDir + "/${name}/cfg.nix")
) (builtins.readDir systemsDir) ) (builtins.readDir systemsDir)
); );
hostsByType = hostsByType = systemType:
systemType: lib.filter (host: ((import (systemsDir + "/${host}/cfg.nix")).syscfg.type or "nixos") == systemType) systemNames;
lib.filter (host: (import (systemsDir + "/${host}/cfg.nix")).syscfg.type == systemType) systemNames; generateHosts = systemType:
generateHosts = lib.genAttrs (hostsByType systemType) (host: gen.generate { inherit host; });
systemType: lib.genAttrs (hostsByType systemType) (host: gen.generate { inherit host; }); in {
flattenPackages =
prefix: attrs:
lib.concatMapAttrs (
name: value:
let
packageName = lib.concatStringsSep "-" (prefix ++ [ name ]);
defaultPackageName = lib.concatStringsSep "-" prefix;
in
if lib.isDerivation value then
{
"${if name == "default" && prefix != [ ] then defaultPackageName else packageName}" = value;
}
else if lib.isAttrs value then
flattenPackages (if name == "default" then prefix else prefix ++ [ name ]) value
else
{ }
) attrs;
mkPackages =
system:
let
pkgs = mkPkgs system;
in
lib.optionalAttrs pkgs.stdenv.isLinux (flattenPackages [ ] pkgs.custom);
in
{
packages = forEachSystem linuxSystems mkPackages;
devShells = import ./shells { devShells = import ./shells {
inherit inputs mkPkgs; inherit inputs mkPkgs;
supportedSystems = linuxSystems; supportedSystems = linuxSystems;
+42 -55
View File
@@ -1,12 +1,6 @@
{ inputs, mkPkgs, supportedSystems, ... }:
{ {
inputs, generate = { host }:
mkPkgs,
supportedSystems,
...
}:
{
generate =
{ host }:
let let
syscfg = import ./systems/${host}/cfg.nix; syscfg = import ./systems/${host}/cfg.nix;
nameValuePair = name: value: { inherit name value; }; nameValuePair = name: value: { inherit name value; };
@@ -18,18 +12,45 @@
home = "x86_64-linux"; home = "x86_64-linux";
} }
.${systemType} or (throw "Unsupported system type: ${systemType}"); .${systemType} or (throw "Unsupported system type: ${systemType}");
system = syscfg.syscfg.system or defaultSystem; requestedSystem = syscfg.syscfg.system or defaultSystem;
checkedSystem = system =
if builtins.elem system supportedSystems then if builtins.elem requestedSystem supportedSystems then
system requestedSystem
else else
throw "Unsupported system '${system}' for host '${host}'"; throw "Unsupported system '${requestedSystem}' for host '${host}'";
pkgs = mkPkgs checkedSystem; users = syscfg.syscfg.users or [ ];
mkLinuxHomeImports =
userConfig:
[
./modules/shared/syscfg
./modules/shared/colors
./modules/home
syscfg
{ usercfg = userConfig; }
inputs.nix-colors.homeManagerModule
inputs.sops-nix.homeManagerModules.sops
];
mkDarwinHomeImports = [ inputs.nix-colors.homeManagerModule inputs.sops-nix.homeManagerModules.sops ];
mkHomeUsers = importsForUser:
builtins.listToAttrs (
map (userConfig: nameValuePair userConfig.username { imports = importsForUser userConfig; }) users
);
mkHomeManager = importsForUser: {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit inputs; };
home-manager.users = mkHomeUsers importsForUser;
};
defaultUser =
builtins.head (
builtins.filter (user: user.username == syscfg.syscfg.defaultUser) users
++ [ { username = syscfg.syscfg.defaultUser; } ]
);
in in
( (
{ {
"nixos" = inputs.nixpkgs.lib.nixosSystem { "nixos" = inputs.nixpkgs.lib.nixosSystem {
system = checkedSystem; inherit system;
specialArgs = { inherit inputs; }; specialArgs = { inherit inputs; };
modules = [ modules = [
./modules/shared/syscfg ./modules/shared/syscfg
@@ -43,32 +64,12 @@
inputs.nixos-wsl.nixosModules.wsl inputs.nixos-wsl.nixosModules.wsl
inputs.vscode-server.nixosModules.default inputs.vscode-server.nixosModules.default
{ (mkHomeManager mkLinuxHomeImports)
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit inputs; };
home-manager.users = builtins.listToAttrs (
map (
userConfig:
nameValuePair userConfig.username {
imports = [
./modules/shared/syscfg
./modules/shared/colors
./modules/home
syscfg
{ usercfg = userConfig; }
inputs.nix-colors.homeManagerModule
inputs.sops-nix.homeManagerModules.sops
];
}
) (syscfg.syscfg.users or [ ])
);
}
]; ];
}; };
"macos" = inputs.darwin.lib.darwinSystem { "macos" = inputs.darwin.lib.darwinSystem {
system = checkedSystem; inherit system;
modules = [ modules = [
./modules/shared/syscfg ./modules/shared/syscfg
./modules/shared/sops ./modules/shared/sops
@@ -76,27 +77,13 @@
./systems/${host} ./systems/${host}
inputs.sops-nix.darwinModules.sops inputs.sops-nix.darwinModules.sops
inputs.home-manager.darwinModules.home-manager inputs.home-manager.darwinModules.home-manager
{ (mkHomeManager (_: mkDarwinHomeImports))
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit inputs; };
home-manager.users = builtins.listToAttrs (
map (
userConfig:
nameValuePair userConfig.username {
imports = [
inputs.nix-colors.homeManagerModule
inputs.sops-nix.homeManagerModules.sops
];
}
) (syscfg.syscfg.users or [ ])
);
}
]; ];
}; };
"home" = inputs.home-manager.lib.homeManagerConfiguration { "home" = inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs; pkgs = mkPkgs system;
modules = [ ./modules/home ]; extraSpecialArgs = { inherit inputs; };
modules = mkLinuxHomeImports defaultUser;
}; };
_ = throw "Unsupported system"; _ = throw "Unsupported system";
} }
+7 -3
View File
@@ -1,12 +1,16 @@
{ lib, config, ... }: { { lib, config, pkgs, ... }: {
#environment.sessionVariables.SOPS_AGE_KEY_FILE = keyFilePath; #environment.sessionVariables.SOPS_AGE_KEY_FILE = keyFilePath;
systemd.user.startServices = "sd-switch"; systemd.user.startServices = lib.mkIf pkgs.stdenv.isLinux "sd-switch";
programs.home-manager.enable = true; programs.home-manager.enable = true;
home = { home = {
username = "${config.usercfg.username}"; username = "${config.usercfg.username}";
homeDirectory = "/home/${config.usercfg.username}"; homeDirectory =
if pkgs.stdenv.isDarwin then
"/Users/${config.usercfg.username}"
else
"/home/${config.usercfg.username}";
stateVersion = "26.05"; stateVersion = "26.05";
}; };
+1 -5
View File
@@ -3,12 +3,8 @@
permittedInsecurePackages = [ ]; permittedInsecurePackages = [ ];
allowUnfree = true; allowUnfree = true;
android_sdk.accept_license = true; android_sdk.accept_license = true;
packageOverrides = pkgs: rec {
custom = import ../../../../packages { inherit pkgs; };
}; };
nixpkgs.overlays = import ../../../../overlays { inherit inputs; };
};
nixpkgs.overlays = import ../../../../overlays { inherit inputs pkgs; };
nix = { nix = {
package = pkgs.nixVersions.stable; package = pkgs.nixVersions.stable;
extraOptions = '' extraOptions = ''
@@ -0,0 +1,2 @@
{ name, ... }:
throw "Container app `${name}` is not implemented yet."
+2 -3
View File
@@ -1,3 +1,2 @@
{...}:{ { name, ... }:
throw "Container app `${name}` is not implemented yet."
}
+3 -1
View File
@@ -16,7 +16,9 @@ let
basePathConfigs = basePathConfigs =
lib.mapAttrsToList (_: cfg: cfg) (lib.filterAttrs (name: _: name != "config" && name != "data") serverCfg.path); lib.mapAttrsToList (_: cfg: cfg) (lib.filterAttrs (name: _: name != "config" && name != "data") serverCfg.path);
runtimePathConfigs = concatRuntimeLists "paths"; runtimePathConfigs = concatRuntimeLists "paths";
allSetupConfigs = map (app: ({ name = app.name; envFile = ""; } // app.runtime.setup)) appsList; allSetupConfigs = builtins.filter
(setup: setup.script != null)
(map (app: ({ name = app.name; envFile = [ ]; } // app.runtime.setup)) appsList);
allCronsConfigs = concatRuntimeLists "cron"; allCronsConfigs = concatRuntimeLists "cron";
allVMConfigs = builtins.filter (app: app.runtime.vm != null) appsList; allVMConfigs = builtins.filter (app: app.runtime.vm != null) appsList;
mkPathSetup = cfg: mkPathSetup = cfg:
+10 -6
View File
@@ -1,11 +1,15 @@
{ inputs, lib, ... }: { lib, ... }:
let let
systemsDir = ../../../systems; systemsDir = ../../../systems;
systemNames = lib.attrNames (lib.filterAttrs isIgnoredSystemDir = name: lib.hasPrefix "_" name || lib.hasPrefix "." name;
(name: type: type == "directory" && builtins.pathExists (systemsDir + "/${name}/cfg.nix")) systemNames = lib.attrNames (
(builtins.readDir systemsDir)); lib.filterAttrs
(name: type:
type == "directory"
&& !isIgnoredSystemDir name
&& builtins.pathExists (systemsDir + "/${name}/cfg.nix"))
(builtins.readDir systemsDir)
);
in with lib; { in with lib; {
options.usercfg = import ./user.nix {inherit lib;}; options.usercfg = import ./user.nix {inherit lib;};
options.syscfg = { options.syscfg = {
+1 -1
View File
@@ -6,6 +6,6 @@ with lib; {
domain = mkOption { type = types.str; default = ""; }; domain = mkOption { type = types.str; default = ""; };
port = mkOption { type = types.str; default = ""; }; port = mkOption { type = types.str; default = ""; };
noProxy = mkOption { type = types.str; default = ""; }; noProxy = mkOption { type = types.str; default = ""; };
cert = mkOption { type = types.path; default = null; }; cert = mkOption { type = types.nullOr types.path; default = null; };
}; };
} }
+1
View File
@@ -5,6 +5,7 @@
#yarn-berry = import ./yarn-berry { inherit final prev; }; #yarn-berry = import ./yarn-berry { inherit final prev; };
#eww = import ./eww { inherit final prev; }; #eww = import ./eww { inherit final prev; };
# ags = import ./ags { inherit final prev; }; # ags = import ./ags { inherit final prev; };
custom = import ../packages { pkgs = final; };
wine = final.unstable.wineWow64Packages.unstableFull; wine = final.unstable.wineWow64Packages.unstableFull;
unstable = import inputs.nixUnstable { unstable = import inputs.nixUnstable {
system = final.stdenv.hostPlatform.system; system = final.stdenv.hostPlatform.system;
-8
View File
@@ -5,12 +5,4 @@
repalette = pkgs.callPackage ./repalette { }; repalette = pkgs.callPackage ./repalette { };
vosk = pkgs.callPackage ./vosk { }; vosk = pkgs.callPackage ./vosk { };
pythonPackages = {
};
nodePackages = {
};
} }
+4 -14
View File
@@ -1,18 +1,8 @@
{ { inputs, mkPkgs, supportedSystems, ... }:
inputs, inputs.nixpkgs.lib.genAttrs supportedSystems (
mkPkgs,
supportedSystems,
...
}:
let
forEachSystem = inputs.nixpkgs.lib.genAttrs supportedSystems;
in
forEachSystem (
system: system:
let let pkgs = mkPkgs system;
pkgs = mkPkgs system; in {
in
{
default = import ./devsh { inherit pkgs; }; default = import ./devsh { inherit pkgs; };
devsh = import ./devsh { inherit pkgs; }; devsh = import ./devsh { inherit pkgs; };
} }