Compare commits

...

6 Commits

Author SHA1 Message Date
Giulio De Pasquale
6a804dded9 refactor(user): use configurable default roles 2025-08-13 10:39:08 +01:00
Giulio De Pasquale
639a43c7d4 docs(commitmessage): remove incorrect character limit requirements 2025-08-13 10:34:52 +01:00
Giulio De Pasquale
4058d5aa2f feat(llm): add docling-serve service and reverse proxy configuration 2025-08-13 10:33:36 +01:00
Giulio De Pasquale
b3368553a2 fix(utils): provide clear error for missing role files 2025-08-13 10:32:33 +01:00
Giulio De Pasquale
c930ef6328 refactor(systems): move system configuration logic to lib/systems.nix
Centralize system configuration setup to reduce duplication and improve maintainability.
2025-08-13 10:30:02 +01:00
Giulio De Pasquale
fd2de0ec29 Claude code ignore 2025-08-13 10:00:24 +01:00
7 changed files with 145 additions and 98 deletions

2
.gitignore vendored
View File

@ -3,3 +3,5 @@ result/
.aider*
.env
**/.claude/settings.local.json

100
flake.nix
View File

@ -35,88 +35,22 @@
sysLinuxAarch = "aarch64-linux";
forAllSystems = nixpkgs.lib.genAttrs [ sysLinuxX64 sysLinuxAarch sysDarwin ];
wrapPkgsSystem = { system, cudaSupport ? false }:
let
config = {
inherit cudaSupport;
allowUnfree = true;
};
cachixOverlay = final: prev: {
nixosModules = (prev.nixosModules or { }) // {
cachixConfig = import ./cachix.nix;
};
};
extOverlays = [
(nvidia-patch.overlays.default)
cachixOverlay
];
importNixpkgs = { flake }:
import flake {
inherit system config;
overlays = extOverlays;
};
unstablePkgs = importNixpkgs { flake = nixos-unstable; };
masterPkgs = importNixpkgs { flake = nixpkgs-master; };
localPkgs = importNixpkgs { flake = local-unstable; };
agenixPkgs = importNixpkgs { flake = agenix-flake; };
pepePkgs = pepeflake.packages.${system} // pepeflake.legacyPackages.${system} or { };
langtoolPkgs = langtool-ngrams.packages.${system} // langtool-ngrams.legacyPackages.${system} or { };
additionalOverlays = [
(final: prev: { inherit unstablePkgs; })
(final: prev: { inherit localPkgs; })
(final: prev: { inherit agenixPkgs; })
(final: prev: { inherit masterPkgs; })
(final: prev: { inherit pepePkgs; })
(final: prev: { inherit langtoolPkgs; })
];
in
import nixpkgs {
inherit system config;
overlays = additionalOverlays ++ extOverlays ++ [
(final: prev: {
ctranslate2 = prev.ctranslate2.override {
withCUDA = true;
withCuDNN = true;
};
})
];
mkSystem = (import ./lib/systems.nix {
inherit nixpkgs;
inputs = {
inherit nixos-unstable nixpkgs-master local-unstable
agenix-flake pepeflake langtool-ngrams
nvidia-patch home-manager;
};
}).mkSystem;
wrapUtils = { pkgs }:
let
inherit (pkgs.lib) makeScope;
inherit (pkgs) newScope;
in
makeScope newScope (self: rec {
inherit nixpkgs home-manager nixos-unstable;
inherit (self.callPackage ./lib/utils.nix { }) mkSysRole mkHomeRole;
inherit (user) mkUser;
user = self.callPackage ./lib/user.nix { };
host = self.callPackage ./lib/host.nix { };
});
pkgsLinuxX64Cuda = wrapPkgsSystem { system = sysLinuxX64; cudaSupport = true; };
utilsLinuxX64Cuda = wrapUtils { pkgs = pkgsLinuxX64Cuda; };
pkgsLinuxAarch = wrapPkgsSystem { system = sysLinuxAarch; };
utilsLinuxAarch = wrapUtils { pkgs = pkgsLinuxAarch; };
pkgsDarwin = wrapPkgsSystem { system = sysDarwin; };
utilsDarwin = wrapUtils { pkgs = pkgsDarwin; };
linuxX64Cuda = mkSystem { system = sysLinuxX64; cudaSupport = true; };
linuxAarch = mkSystem { system = sysLinuxAarch; };
darwin = mkSystem { system = sysDarwin; };
in
{
nixosConfigurations = {
architect = utilsLinuxX64Cuda.host.mkHost {
architect = linuxX64Cuda.utils.host.mkHost {
name = "architect";
users = [{
user = "giulio";
@ -129,27 +63,27 @@
};
homeConfigurations = {
giulioMac = utilsDarwin.user.mkHMUser {
giulioMac = darwin.utils.user.mkHMUser {
name = "giulio";
roles = [ "ssh" ];
};
gdepasqualeMac = utilsDarwin.user.mkHMUser {
gdepasqualeMac = darwin.utils.user.mkHMUser {
name = "gdepasquale";
roles = [ "ssh" ];
};
giulioAarch = utilsLinuxAarch.user.mkHMUser {
giulioAarch = linuxAarch.utils.user.mkHMUser {
name = "giulio";
roles = [ "ssh" ];
};
giulioX64 = utilsLinuxX64Cuda.user.mkHMUser {
giulioX64 = linuxX64Cuda.utils.user.mkHMUser {
name = "giulio";
roles = [ "ssh" "go" ];
};
giulioX64NoSSH = utilsLinuxX64Cuda.user.mkHMUser {
giulioX64NoSSH = linuxX64Cuda.utils.user.mkHMUser {
name = "giulio";
roles = [ "go" ];
};
gdepasqualeX64 = utilsLinuxX64Cuda.user.mkHMUser {
gdepasqualeX64 = linuxX64Cuda.utils.user.mkHMUser {
name = "gdepasquale";
roles = [ "ssh" "go" ];
};

72
lib/systems.nix Normal file
View File

@ -0,0 +1,72 @@
{ nixpkgs, inputs }:
let
mkSystem = { system, cudaSupport ? false }:
let
config = {
inherit cudaSupport;
allowUnfree = true;
};
cachixOverlay = final: prev: {
nixosModules = (prev.nixosModules or { }) // {
cachixConfig = import ../cachix.nix;
};
};
extOverlays = [
(inputs.nvidia-patch.overlays.default)
cachixOverlay
];
importNixpkgs = { flake }:
import flake {
inherit system config;
overlays = extOverlays;
};
unstablePkgs = importNixpkgs { flake = inputs.nixos-unstable; };
masterPkgs = importNixpkgs { flake = inputs.nixpkgs-master; };
localPkgs = importNixpkgs { flake = inputs.local-unstable; };
agenixPkgs = importNixpkgs { flake = inputs.agenix-flake; };
pepePkgs = inputs.pepeflake.packages.${system} // inputs.pepeflake.legacyPackages.${system} or { };
langtoolPkgs = inputs.langtool-ngrams.packages.${system} // inputs.langtool-ngrams.legacyPackages.${system} or { };
additionalOverlays = [
(final: prev: { inherit unstablePkgs; })
(final: prev: { inherit localPkgs; })
(final: prev: { inherit agenixPkgs; })
(final: prev: { inherit masterPkgs; })
(final: prev: { inherit pepePkgs; })
(final: prev: { inherit langtoolPkgs; })
];
pkgs = import nixpkgs {
inherit system config;
overlays = additionalOverlays ++ extOverlays ++ [
(final: prev: {
ctranslate2 = prev.ctranslate2.override {
withCUDA = cudaSupport;
withCuDNN = cudaSupport;
};
})
];
};
utils =
let
inherit (pkgs.lib) makeScope;
inherit (pkgs) newScope;
in
makeScope newScope (self: rec {
inherit nixpkgs inputs;
inherit (self.callPackage ../lib/utils.nix { }) mkSysRole mkHomeRole;
inherit (user) mkUser;
user = self.callPackage ../lib/user.nix { home-manager = inputs.home-manager; };
host = self.callPackage ../lib/host.nix { home-manager = inputs.home-manager; };
});
in
{ inherit pkgs utils; };
in
{ inherit mkSystem; }

View File

@ -5,10 +5,18 @@
, ...
}:
let
# Default roles that all NixOS users get
defaultSystemUserRoles = [ "common" "zsh" "aichat" ];
# Default roles for standalone home-manager configs
defaultHMUserRoles = [ "common" "aichat" ];
in
{
mkUser = { name, roles ? [ ] }:
mkUser = { name, roles ? [ ], defaultRoles ? defaultSystemUserRoles }:
let
roles_mod = (map (r: mkHomeRole r) roles);
defaults_mod = (map (r: mkHomeRole r) defaultRoles);
in
{
fileSystems."/home/${name}/Downloads" = pkgs.lib.mkIf stdenv.isLinux {
@ -27,16 +35,13 @@
programs.zsh.enable = true;
home-manager.users.${name}.imports = [
(mkHomeRole "common")
(mkHomeRole "zsh")
(mkHomeRole "aichat")
] ++ roles_mod;
home-manager.users.${name}.imports = defaults_mod ++ roles_mod;
};
mkHMUser = { name, roles ? [ ] }:
mkHMUser = { name, roles ? [ ], defaultRoles ? defaultHMUserRoles }:
let
roles_mod = (map (r: mkHomeRole r) roles);
defaults_mod = (map (r: mkHomeRole r) defaultRoles);
in
home-manager.lib.homeManagerConfiguration {
inherit pkgs;
@ -48,8 +53,6 @@
if stdenv.isLinux then "/home/${name}" else "/Users/${name}";
};
}
(mkHomeRole "common")
(mkHomeRole "aichat")
] ++ roles_mod;
] ++ defaults_mod ++ roles_mod;
};
}

View File

@ -1,6 +1,24 @@
{ ... }:
let
mkSysRole = role:
let
path = ../roles + "/${role}.nix";
in
if builtins.pathExists path then
import path
else
throw "System role '${role}' not found at ${toString path}";
mkHomeRole = role:
let
path = ../roles/home + "/${role}.nix";
in
if builtins.pathExists path then
import path
else
throw "Home role '${role}' not found at ${toString path}";
in
{
mkSysRole = role: import (../roles/${role}.nix);
mkHomeRole = role: import (../roles/home/${role}.nix);
inherit mkSysRole mkHomeRole;
}

View File

@ -61,6 +61,11 @@ in
environmentVariables = cfg.environmentVariables;
};
services.docling-serve = {
enable = true;
package = pkgs.unstablePkgs.docling-serve;
};
pepe.core.vhost.hosts = optionalAttrs (cfg.backendDomain != null) {
"${cfg.backendDomain}" = {
locations."/" = {
@ -76,6 +81,21 @@ in
proxy_set_header Host localhost:${toString config.services.ollama.port};
'';
};
locations."/docling/" = {
host = config.services.docling-serve.host;
port = config.services.docling-serve.port;
allowLAN = true;
allowVPN = true;
allowWAN = true;
recommendedProxySettings = false;
extraConfig = ''
proxy_buffering off;
proxy_read_timeout 600s;
rewrite ^/docling/(.*) /$1 break;
'';
};
};
};
})

View File

@ -31,7 +31,6 @@ You must adhere to the following rules without exception:
3. **Scope**: The `(scope)` is optional. If used, it must be a noun describing the section of the codebase affected.
4. **Subject**: The `<subject>` line:
* Must be 50 characters or less.
* Must be written in the imperative mood (e.g., "Add feature", not "Added feature" or "Adds feature").
* Must not be capitalized.
* Must not end with a period.
@ -39,7 +38,6 @@ You must adhere to the following rules without exception:
5. **Body**: The `[body]` is optional but highly encouraged for anything other than trivial changes.
* It must be separated from the subject by one blank line.
* It must explain the "what" and "why" of the change, not the "how".
* Each line must be wrapped at 72 characters.
6. **Output**: Your final output must be ONLY the raw text of the commit message and nothing else. Do not include any explanations, apologies, or surrounding markdown like ` ``` `.
@ -97,4 +95,4 @@ index 0000000..d67e2a9
+ * **test**: Adding missing tests or correcting existing tests.
+ * **build**: Changes that affect the build system or external dependencies.
+ * **ci**: Changes to our CI configuration files and scripts.
+ * **chore**: Other changes that don't modify src or test files.
+ * **chore**: Other changes that don't modify src or test files.