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"
}
},
"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",

View file

@ -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";
};

View file

@ -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 {

View file

@ -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"
'';

View file

@ -36,6 +36,7 @@
inputs.nixos-hardware.nixosModules.raspberry-pi-4
./pie
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, ... }: {
# 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;
};
};
}

View file

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

View file

@ -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

View file

@ -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;

View file

@ -1,22 +1,14 @@
{
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";
};
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"];
@ -24,10 +16,22 @@ in {
services.printing.defaultShared = false;
services.printing.drivers = [
pkgs.gutenprint
pkgs.cups-brother-hl3140cw
];
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
}
'';
};
}

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:
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);