Compare commits

..

1 Commits

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