diff --git a/flake.lock b/flake.lock index 1983625..c9ae64e 100644 --- a/flake.lock +++ b/flake.lock @@ -252,6 +252,21 @@ "type": "github" } }, + "hl3140cw-arm": { + "locked": { + "lastModified": 1696674831, + "narHash": "sha256-FJmtrlRWJ76GwSaUB/Y7UCkfqgYh7wsnLOgVe15YvqU=", + "ref": "refs/heads/feat/brother-hl3140cw-on-arm", + "rev": "060f8d9b2493166afc9a48e274ea38cbefb38549", + "revCount": 533407, + "type": "git", + "url": "https://git.pub.solar/b12f/nixpkgs.git?branch=feat%2fbrotherhl3140cw-on-arm" + }, + "original": { + "type": "git", + "url": "https://git.pub.solar/b12f/nixpkgs.git?branch=feat%2fbrotherhl3140cw-on-arm" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -479,6 +494,7 @@ "deploy-rs": "deploy-rs", "flake-compat": "flake-compat", "flake-parts": "flake-parts", + "hl3140cw-arm": "hl3140cw-arm", "home-manager": "home-manager", "mobile-nixos": "mobile-nixos", "musnix": "musnix", diff --git a/flake.nix b/flake.nix index d0c1605..ee580d9 100644 --- a/flake.nix +++ b/flake.nix @@ -35,9 +35,13 @@ mobile-nixos.flake = false; scan2paperless.url = "git+https://git.pub.solar/b12f/scan2paperless.git"; + musnix.url = "github:musnix/musnix"; + adblock-unbound.url = "github:MayNiklas/nixos-adblock-unbound"; adblock-unbound.inputs.nixpkgs.follows = "nixpkgs"; + + hl3140cw-arm.url = "git+https://git.pub.solar/b12f/nixpkgs.git?branch=feat/brotherhl3140cw-on-arm"; }; outputs = inputs@{ self, ... }: @@ -57,14 +61,12 @@ ./users ]; - perSystem = args@{ system, pkgs, config, ... }: { + perSystem = args@{ system, pkgs, lib, config, ... }: { _module.args = { inherit inputs; pkgs = import inputs.nixpkgs { inherit system; - overlays = [ - inputs.agenix.overlays.default - ]; + overlays = [ inputs.agenix.overlays.default ]; }; }; @@ -87,7 +89,7 @@ }; flake = { - deploy.nodes = self.b12f-os.lib.deploy.mkDeployNodes self.nixosConfigurations { + deploy.nodes = self.lib.deploy.mkDeployNodes self.nixosConfigurations { chocolatebar = { sshUser = "b12f"; }; diff --git a/hosts/biolimo/configuration.nix b/hosts/biolimo/configuration.nix index 88fd884..e84ee41 100644 --- a/hosts/biolimo/configuration.nix +++ b/hosts/biolimo/configuration.nix @@ -25,10 +25,6 @@ in { networking.hostName = "biolimo"; networking.networkmanager.wifi.backend = mkForce "wpa_supplicant"; - services.printing.drivers = [ - pkgs.cups-brother-hl3140cw - ]; - home-manager = with pkgs; pkgs.lib.setAttrByPath ["users" psCfg.user.name] { xdg.configFile = mkIf psCfg.sway.enable { diff --git a/hosts/chocolatebar/configuration.nix b/hosts/chocolatebar/configuration.nix index 0e787b1..aa5c9ed 100644 --- a/hosts/chocolatebar/configuration.nix +++ b/hosts/chocolatebar/configuration.nix @@ -73,10 +73,6 @@ in { }; pub-solar.sway.vnc.enable = true; - services.printing.drivers = [ - pkgs.cups-brother-hl3140cw - ]; - services.udev.extraRules = '' SUBSYSTEMS=="usb", ATTRS{idVendor}=="04f9", ATTRS{idProduct}=="209e", ATTRS{serial}=="000W0H924252", MODE="0664", GROUP="lp", SYMLINK+="usb/lp0" ''; diff --git a/hosts/default.nix b/hosts/default.nix index 8d8ccd7..57dc259 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -36,6 +36,7 @@ inputs.nixos-hardware.nixosModules.raspberry-pi-4 ./pie self.nixosModules.yule + self.nixosModules.printing ]; }; diff --git a/lib/add-local-hostname.nix b/lib/add-local-hostname.nix new file mode 100644 index 0000000..6940fa8 --- /dev/null +++ b/lib/add-local-hostname.nix @@ -0,0 +1,5 @@ +{ lib }: +hostnames: { + "127.0.0.1" = hostnames; + "::1" = hostnames; +} diff --git a/lib/default.nix b/lib/default.nix index 4e39d82..49bbaf4 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,7 +1,7 @@ { lib, inputs, ... }: { # Configuration common to all Linux systems flake = { - b12f-os.lib = let + lib = let callLibs = file: import file {inherit lib;}; in rec { ## Define your own library functions here! @@ -11,6 +11,8 @@ ## In configs, they can be used under "lib.our" deploy = import ./deploy.nix { inherit inputs lib; }; + + addLocalHostname = callLibs ./add-local-hostname.nix; }; }; } diff --git a/modules/core/networking.nix b/modules/core/networking.nix index ddd41b8..51d1c9c 100644 --- a/modules/core/networking.nix +++ b/modules/core/networking.nix @@ -40,59 +40,5 @@ in { }; networking.firewall.enable = true; - - # Customized binary caches list (with fallback to official binary cache) - nix.settings.substituters = cfg.binaryCaches; - nix.settings.trusted-public-keys = cfg.publicKeys; - - # These entries get added to /etc/hosts - networking.hosts = let - hostnames = - [] - ++ lib.optionals cfg.enableCaddy ["caddy.local"] - ++ lib.optionals config.pub-solar.printing.enable ["cups.local"] - ++ lib.optionals config.pub-solar.paperless.enable ["paperless.local"] - ++ lib.optionals cfg.enableHelp ["help.local"]; - in { - "127.0.0.1" = hostnames; - "::1" = hostnames; - }; - - # Caddy reverse proxy for local services like cups - services.caddy = { - enable = cfg.enableCaddy; - globalConfig = '' - default_bind 127.0.0.1 - auto_https off - ''; - extraConfig = (concatStringsSep "\n" [ - (lib.optionalString - config.pub-solar.printing.enable - '' - cups.local:80 { - request_header Host localhost:631 - reverse_proxy unix//run/cups/cups.sock - } - '') - - (lib.optionalString - config.pub-solar.paperless.enable - '' - paperless.local:80 { - request_header Host localhost:${builtins.toString config.services.paperless.port} - reverse_proxy localhost:${builtins.toString config.services.paperless.port} - } - '') - - (lib.optionalString - cfg.enableHelp - '' - help.local:80 { - root * ${pkgs.psos-docs}/lib/html - file_server - } - '') - ]); - }; }; } diff --git a/modules/default.nix b/modules/default.nix index 9764f4c..1a87694 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -24,6 +24,7 @@ paperless = import ./paperless; paranoia = import ./paranoia; printing = import ./printing; + proxy = import ./proxy; social = import ./social; sway = import ./sway; terminal-life = import ./terminal-life; @@ -36,11 +37,16 @@ inputs.agenix.nixosModules.default inputs.musnix.nixosModules.musnix - ({ flake, pkgs, lib, ... }: { + ({ ... }: { nixpkgs.overlays = [ - (prev: next: { + (final: prev: { nixd = inputs.nixpkgs-unstable.legacyPackages.${prev.system}.nixd; + cups-brother-hl3140cw = (import inputs.hl3140cw-arm { + system = prev.system; + config.allowUnfree = true; + }).cups-brother-hl3140cw; + factorio-headless = inputs.nixpkgs-master.legacyPackages.${prev.system}.factorio-headless; paperless-ngx = inputs.nixpkgs-master.legacyPackages.${prev.system}.paperless-ngx; waybar = inputs.nixpkgs-master.legacyPackages.${prev.system}.waybar; @@ -77,7 +83,8 @@ self.nixosModules.office self.nixosModules.paperless self.nixosModules.paranoia - self.nixosModules.printing + # self.nixosModules.printing + self.nixosModules.proxy self.nixosModules.social self.nixosModules.sway self.nixosModules.terminal-life diff --git a/modules/office/default.nix b/modules/office/default.nix index dcfb688..ab8d171 100644 --- a/modules/office/default.nix +++ b/modules/office/default.nix @@ -13,8 +13,6 @@ in { }; config = mkIf cfg.enable { - pub-solar.printing.enable = true; - # Gnome PDF viewer programs.evince.enable = true; home-manager = with pkgs; diff --git a/modules/printing/default.nix b/modules/printing/default.nix index 2dc9d03..0c49bab 100644 --- a/modules/printing/default.nix +++ b/modules/printing/default.nix @@ -1,33 +1,37 @@ { - lib, + flake, config, pkgs, + lib, ... -}: -with lib; let - psCfg = config.pub-solar; - cfg = config.pub-solar.printing; -in { - options.pub-solar.printing = { - enable = mkEnableOption "CUPSSSss"; +}: { + services.avahi.nssmdns = true; + services.avahi.publish.enable = true; + services.avahi.publish.userServices = true; + + services.printing.enable = true; + services.printing.browsing = true; + services.printing.listenAddresses = ["localhost:631"]; + services.printing.allowFrom = ["all"]; + services.printing.defaultShared = false; + services.printing.drivers = [ + pkgs.gutenprint + pkgs.cups-brother-hl3140cw + ]; + + hardware.sane = { + enable = true; + extraBackends = [pkgs.hplipWithPlugin]; }; - config = mkIf cfg.enable { - services.avahi.enable = true; - services.avahi.nssmdns = true; - services.avahi.publish.enable = true; - services.avahi.publish.userServices = true; - services.printing.enable = true; - services.printing.browsing = true; - services.printing.listenAddresses = ["localhost:631"]; - services.printing.allowFrom = ["all"]; - services.printing.defaultShared = false; - services.printing.drivers = [ - pkgs.gutenprint - ]; - hardware.sane = { - enable = true; - extraBackends = [pkgs.hplipWithPlugin]; - }; + networking.hosts = flake.self.lib.addLocalHostname ["cups.local"]; + + services.caddy = { + extraConfig = '' + cups.local:80 { + request_header Host localhost:631 + reverse_proxy unix//run/cups/cups.sock + } + ''; }; } diff --git a/modules/proxy/default.nix b/modules/proxy/default.nix new file mode 100644 index 0000000..92184b9 --- /dev/null +++ b/modules/proxy/default.nix @@ -0,0 +1,28 @@ +{ + flake, + config, + pkgs, + lib, + ... +}: { + networking.hosts = flake.self.lib.addLocalHostname ["caddy.local"]; + + # Caddy reverse proxy for local services like cups + services.caddy = { + enable = true; + globalConfig = '' + default_bind 127.0.0.1 + auto_https off + ''; + extraConfig = (lib.concatStringsSep "\n" [ + (lib.optionalString + config.pub-solar.paperless.enable + '' + paperless.local:80 { + request_header Host localhost:${builtins.toString config.services.paperless.port} + reverse_proxy localhost:${builtins.toString config.services.paperless.port} + } + '') + ]); + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 6281e07..142806b 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,7 +1,7 @@ final: prev: -with final; { +with prev; { # keep sources this first - sources = prev.callPackage (import ./_sources/generated.nix) {}; + sources = callPackage (import ./_sources/generated.nix) {}; # then, call packages with `final.callPackage` concourse = import ./concourse.nix final; import-gtk-settings = writeShellScriptBin "import-gtk-settings" (import ./import-gtk-settings.nix final);