refactor: more printing to pie

This commit is contained in:
Benjamin Bädorf 2023-10-07 14:06:28 +02:00
parent 6d7564eb0e
commit 078e738a31
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C
13 changed files with 101 additions and 100 deletions

View file

@ -252,6 +252,21 @@
"type": "github" "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": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -479,6 +494,7 @@
"deploy-rs": "deploy-rs", "deploy-rs": "deploy-rs",
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"hl3140cw-arm": "hl3140cw-arm",
"home-manager": "home-manager", "home-manager": "home-manager",
"mobile-nixos": "mobile-nixos", "mobile-nixos": "mobile-nixos",
"musnix": "musnix", "musnix": "musnix",

View file

@ -35,9 +35,13 @@
mobile-nixos.flake = false; mobile-nixos.flake = false;
scan2paperless.url = "git+https://git.pub.solar/b12f/scan2paperless.git"; scan2paperless.url = "git+https://git.pub.solar/b12f/scan2paperless.git";
musnix.url = "github:musnix/musnix"; musnix.url = "github:musnix/musnix";
adblock-unbound.url = "github:MayNiklas/nixos-adblock-unbound"; adblock-unbound.url = "github:MayNiklas/nixos-adblock-unbound";
adblock-unbound.inputs.nixpkgs.follows = "nixpkgs"; 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, ... }: outputs = inputs@{ self, ... }:
@ -57,14 +61,12 @@
./users ./users
]; ];
perSystem = args@{ system, pkgs, config, ... }: { perSystem = args@{ system, pkgs, lib, config, ... }: {
_module.args = { _module.args = {
inherit inputs; inherit inputs;
pkgs = import inputs.nixpkgs { pkgs = import inputs.nixpkgs {
inherit system; inherit system;
overlays = [ overlays = [ inputs.agenix.overlays.default ];
inputs.agenix.overlays.default
];
}; };
}; };
@ -87,7 +89,7 @@
}; };
flake = { flake = {
deploy.nodes = self.b12f-os.lib.deploy.mkDeployNodes self.nixosConfigurations { deploy.nodes = self.lib.deploy.mkDeployNodes self.nixosConfigurations {
chocolatebar = { chocolatebar = {
sshUser = "b12f"; sshUser = "b12f";
}; };

View file

@ -25,10 +25,6 @@ in {
networking.hostName = "biolimo"; networking.hostName = "biolimo";
networking.networkmanager.wifi.backend = mkForce "wpa_supplicant"; networking.networkmanager.wifi.backend = mkForce "wpa_supplicant";
services.printing.drivers = [
pkgs.cups-brother-hl3140cw
];
home-manager = with pkgs; home-manager = with pkgs;
pkgs.lib.setAttrByPath ["users" psCfg.user.name] { pkgs.lib.setAttrByPath ["users" psCfg.user.name] {
xdg.configFile = mkIf psCfg.sway.enable { xdg.configFile = mkIf psCfg.sway.enable {

View file

@ -73,10 +73,6 @@ in {
}; };
pub-solar.sway.vnc.enable = true; pub-solar.sway.vnc.enable = true;
services.printing.drivers = [
pkgs.cups-brother-hl3140cw
];
services.udev.extraRules = '' services.udev.extraRules = ''
SUBSYSTEMS=="usb", ATTRS{idVendor}=="04f9", ATTRS{idProduct}=="209e", ATTRS{serial}=="000W0H924252", MODE="0664", GROUP="lp", SYMLINK+="usb/lp0" SUBSYSTEMS=="usb", ATTRS{idVendor}=="04f9", ATTRS{idProduct}=="209e", ATTRS{serial}=="000W0H924252", MODE="0664", GROUP="lp", SYMLINK+="usb/lp0"
''; '';

View file

@ -36,6 +36,7 @@
inputs.nixos-hardware.nixosModules.raspberry-pi-4 inputs.nixos-hardware.nixosModules.raspberry-pi-4
./pie ./pie
self.nixosModules.yule self.nixosModules.yule
self.nixosModules.printing
]; ];
}; };

View file

@ -0,0 +1,5 @@
{ lib }:
hostnames: {
"127.0.0.1" = hostnames;
"::1" = hostnames;
}

View file

@ -1,7 +1,7 @@
{ lib, inputs, ... }: { { lib, inputs, ... }: {
# Configuration common to all Linux systems # Configuration common to all Linux systems
flake = { flake = {
b12f-os.lib = let lib = let
callLibs = file: import file {inherit lib;}; callLibs = file: import file {inherit lib;};
in rec { in rec {
## Define your own library functions here! ## Define your own library functions here!
@ -11,6 +11,8 @@
## In configs, they can be used under "lib.our" ## In configs, they can be used under "lib.our"
deploy = import ./deploy.nix { inherit inputs lib; }; deploy = import ./deploy.nix { inherit inputs lib; };
addLocalHostname = callLibs ./add-local-hostname.nix;
}; };
}; };
} }

View file

@ -40,59 +40,5 @@ in {
}; };
networking.firewall.enable = true; 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
}
'')
]);
};
}; };
} }

View file

@ -24,6 +24,7 @@
paperless = import ./paperless; paperless = import ./paperless;
paranoia = import ./paranoia; paranoia = import ./paranoia;
printing = import ./printing; printing = import ./printing;
proxy = import ./proxy;
social = import ./social; social = import ./social;
sway = import ./sway; sway = import ./sway;
terminal-life = import ./terminal-life; terminal-life = import ./terminal-life;
@ -36,11 +37,16 @@
inputs.agenix.nixosModules.default inputs.agenix.nixosModules.default
inputs.musnix.nixosModules.musnix inputs.musnix.nixosModules.musnix
({ flake, pkgs, lib, ... }: { ({ ... }: {
nixpkgs.overlays = [ nixpkgs.overlays = [
(prev: next: { (final: prev: {
nixd = inputs.nixpkgs-unstable.legacyPackages.${prev.system}.nixd; 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; factorio-headless = inputs.nixpkgs-master.legacyPackages.${prev.system}.factorio-headless;
paperless-ngx = inputs.nixpkgs-master.legacyPackages.${prev.system}.paperless-ngx; paperless-ngx = inputs.nixpkgs-master.legacyPackages.${prev.system}.paperless-ngx;
waybar = inputs.nixpkgs-master.legacyPackages.${prev.system}.waybar; waybar = inputs.nixpkgs-master.legacyPackages.${prev.system}.waybar;
@ -77,7 +83,8 @@
self.nixosModules.office self.nixosModules.office
self.nixosModules.paperless self.nixosModules.paperless
self.nixosModules.paranoia self.nixosModules.paranoia
self.nixosModules.printing # self.nixosModules.printing
self.nixosModules.proxy
self.nixosModules.social self.nixosModules.social
self.nixosModules.sway self.nixosModules.sway
self.nixosModules.terminal-life self.nixosModules.terminal-life

View file

@ -13,8 +13,6 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
pub-solar.printing.enable = true;
# Gnome PDF viewer # Gnome PDF viewer
programs.evince.enable = true; programs.evince.enable = true;
home-manager = with pkgs; home-manager = with pkgs;

View file

@ -1,22 +1,14 @@
{ {
lib, flake,
config, config,
pkgs, pkgs,
lib,
... ...
}: }: {
with lib; let
psCfg = config.pub-solar;
cfg = config.pub-solar.printing;
in {
options.pub-solar.printing = {
enable = mkEnableOption "CUPSSSss";
};
config = mkIf cfg.enable {
services.avahi.enable = true;
services.avahi.nssmdns = true; services.avahi.nssmdns = true;
services.avahi.publish.enable = true; services.avahi.publish.enable = true;
services.avahi.publish.userServices = true; services.avahi.publish.userServices = true;
services.printing.enable = true; services.printing.enable = true;
services.printing.browsing = true; services.printing.browsing = true;
services.printing.listenAddresses = ["localhost:631"]; services.printing.listenAddresses = ["localhost:631"];
@ -24,10 +16,22 @@ in {
services.printing.defaultShared = false; services.printing.defaultShared = false;
services.printing.drivers = [ services.printing.drivers = [
pkgs.gutenprint pkgs.gutenprint
pkgs.cups-brother-hl3140cw
]; ];
hardware.sane = { hardware.sane = {
enable = true; enable = true;
extraBackends = [pkgs.hplipWithPlugin]; 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
}
'';
}; };
} }

28
modules/proxy/default.nix Normal file
View file

@ -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}
}
'')
]);
};
}

View file

@ -1,7 +1,7 @@
final: prev: final: prev:
with final; { with prev; {
# keep sources this first # keep sources this first
sources = prev.callPackage (import ./_sources/generated.nix) {}; sources = callPackage (import ./_sources/generated.nix) {};
# then, call packages with `final.callPackage` # then, call packages with `final.callPackage`
concourse = import ./concourse.nix final; concourse = import ./concourse.nix final;
import-gtk-settings = writeShellScriptBin "import-gtk-settings" (import ./import-gtk-settings.nix final); import-gtk-settings = writeShellScriptBin "import-gtk-settings" (import ./import-gtk-settings.nix final);