Compare commits

..

No commits in common. "6a804dded9197b9f04fdc5c0d9ae9cd293431d9c" and "596081838e529f0cf4b0d47091b8b30874900d8d" have entirely different histories.

7 changed files with 99 additions and 146 deletions

2
.gitignore vendored
View File

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

102
flake.nix
View File

@ -35,22 +35,88 @@
sysLinuxAarch = "aarch64-linux"; sysLinuxAarch = "aarch64-linux";
forAllSystems = nixpkgs.lib.genAttrs [ sysLinuxX64 sysLinuxAarch sysDarwin ]; forAllSystems = nixpkgs.lib.genAttrs [ sysLinuxX64 sysLinuxAarch sysDarwin ];
mkSystem = (import ./lib/systems.nix { wrapPkgsSystem = { system, cudaSupport ? false }:
inherit nixpkgs; let
inputs = { config = {
inherit nixos-unstable nixpkgs-master local-unstable inherit cudaSupport;
agenix-flake pepeflake langtool-ngrams
nvidia-patch home-manager;
};
}).mkSystem;
linuxX64Cuda = mkSystem { system = sysLinuxX64; cudaSupport = true; }; allowUnfree = true;
linuxAarch = mkSystem { system = sysLinuxAarch; }; };
darwin = mkSystem { system = sysDarwin; };
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;
};
})
];
};
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; };
in in
{ {
nixosConfigurations = { nixosConfigurations = {
architect = linuxX64Cuda.utils.host.mkHost { architect = utilsLinuxX64Cuda.host.mkHost {
name = "architect"; name = "architect";
users = [{ users = [{
user = "giulio"; user = "giulio";
@ -63,27 +129,27 @@
}; };
homeConfigurations = { homeConfigurations = {
giulioMac = darwin.utils.user.mkHMUser { giulioMac = utilsDarwin.user.mkHMUser {
name = "giulio"; name = "giulio";
roles = [ "ssh" ]; roles = [ "ssh" ];
}; };
gdepasqualeMac = darwin.utils.user.mkHMUser { gdepasqualeMac = utilsDarwin.user.mkHMUser {
name = "gdepasquale"; name = "gdepasquale";
roles = [ "ssh" ]; roles = [ "ssh" ];
}; };
giulioAarch = linuxAarch.utils.user.mkHMUser { giulioAarch = utilsLinuxAarch.user.mkHMUser {
name = "giulio"; name = "giulio";
roles = [ "ssh" ]; roles = [ "ssh" ];
}; };
giulioX64 = linuxX64Cuda.utils.user.mkHMUser { giulioX64 = utilsLinuxX64Cuda.user.mkHMUser {
name = "giulio"; name = "giulio";
roles = [ "ssh" "go" ]; roles = [ "ssh" "go" ];
}; };
giulioX64NoSSH = linuxX64Cuda.utils.user.mkHMUser { giulioX64NoSSH = utilsLinuxX64Cuda.user.mkHMUser {
name = "giulio"; name = "giulio";
roles = [ "go" ]; roles = [ "go" ];
}; };
gdepasqualeX64 = linuxX64Cuda.utils.user.mkHMUser { gdepasqualeX64 = utilsLinuxX64Cuda.user.mkHMUser {
name = "gdepasquale"; name = "gdepasquale";
roles = [ "ssh" "go" ]; roles = [ "ssh" "go" ];
}; };

View File

@ -1,72 +0,0 @@
{ 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,18 +5,10 @@
, ... , ...
}: }:
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 ? [ ], defaultRoles ? defaultSystemUserRoles }: mkUser = { name, roles ? [ ] }:
let let
roles_mod = (map (r: mkHomeRole r) roles); roles_mod = (map (r: mkHomeRole r) roles);
defaults_mod = (map (r: mkHomeRole r) defaultRoles);
in in
{ {
fileSystems."/home/${name}/Downloads" = pkgs.lib.mkIf stdenv.isLinux { fileSystems."/home/${name}/Downloads" = pkgs.lib.mkIf stdenv.isLinux {
@ -35,13 +27,16 @@ in
programs.zsh.enable = true; programs.zsh.enable = true;
home-manager.users.${name}.imports = defaults_mod ++ roles_mod; home-manager.users.${name}.imports = [
(mkHomeRole "common")
(mkHomeRole "zsh")
(mkHomeRole "aichat")
] ++ roles_mod;
}; };
mkHMUser = { name, roles ? [ ], defaultRoles ? defaultHMUserRoles }: mkHMUser = { name, roles ? [ ] }:
let let
roles_mod = (map (r: mkHomeRole r) roles); roles_mod = (map (r: mkHomeRole r) roles);
defaults_mod = (map (r: mkHomeRole r) defaultRoles);
in in
home-manager.lib.homeManagerConfiguration { home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;
@ -53,6 +48,8 @@ in
if stdenv.isLinux then "/home/${name}" else "/Users/${name}"; if stdenv.isLinux then "/home/${name}" else "/Users/${name}";
}; };
} }
] ++ defaults_mod ++ roles_mod; (mkHomeRole "common")
(mkHomeRole "aichat")
] ++ roles_mod;
}; };
} }

View File

@ -1,24 +1,6 @@
{ ... }: { ... }:
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
{ {
inherit mkSysRole mkHomeRole; mkSysRole = role: import (../roles/${role}.nix);
mkHomeRole = role: import (../roles/home/${role}.nix);
} }

View File

@ -61,11 +61,6 @@ in
environmentVariables = cfg.environmentVariables; environmentVariables = cfg.environmentVariables;
}; };
services.docling-serve = {
enable = true;
package = pkgs.unstablePkgs.docling-serve;
};
pepe.core.vhost.hosts = optionalAttrs (cfg.backendDomain != null) { pepe.core.vhost.hosts = optionalAttrs (cfg.backendDomain != null) {
"${cfg.backendDomain}" = { "${cfg.backendDomain}" = {
locations."/" = { locations."/" = {
@ -81,21 +76,6 @@ in
proxy_set_header Host localhost:${toString config.services.ollama.port}; 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,6 +31,7 @@ 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. 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: 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 be written in the imperative mood (e.g., "Add feature", not "Added feature" or "Adds feature").
* Must not be capitalized. * Must not be capitalized.
* Must not end with a period. * Must not end with a period.
@ -38,6 +39,7 @@ You must adhere to the following rules without exception:
5. **Body**: The `[body]` is optional but highly encouraged for anything other than trivial changes. 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 be separated from the subject by one blank line.
* It must explain the "what" and "why" of the change, not the "how". * 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 ` ``` `. 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 ` ``` `.
@ -95,4 +97,4 @@ index 0000000..d67e2a9
+ * **test**: Adding missing tests or correcting existing tests. + * **test**: Adding missing tests or correcting existing tests.
+ * **build**: Changes that affect the build system or external dependencies. + * **build**: Changes that affect the build system or external dependencies.
+ * **ci**: Changes to our CI configuration files and scripts. + * **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.