From cc176135e0d822bf93bc75711af625a999576971 Mon Sep 17 00:00:00 2001 From: Jez Cope Date: Fri, 6 Aug 2021 12:09:21 +0100 Subject: [PATCH] meta: refactor "bits" -> "profiles" --- bits/amdgpu.nix | 19 -------------- bits/foldingathome.nix | 22 ---------------- bits/home-common.nix | 38 --------------------------- bits/ipfs.nix | 13 --------- bits/zfs.nix | 17 ------------ flake.nix | 1 + hosts/arianrhod/default.nix | 3 ++- hosts/gwydion/default.nix | 10 ++----- profiles/amdgpu/default.nix | 23 ++++++++++++++++ profiles/default.nix | 12 +++++++++ profiles/foldingathome/default.nix | 26 ++++++++++++++++++ profiles/home/default.nix | 42 ++++++++++++++++++++++++++++++ profiles/ipfs/default.nix | 17 ++++++++++++ profiles/zfs/default.nix | 21 +++++++++++++++ 14 files changed, 146 insertions(+), 118 deletions(-) delete mode 100644 bits/amdgpu.nix delete mode 100644 bits/foldingathome.nix delete mode 100644 bits/home-common.nix delete mode 100644 bits/ipfs.nix delete mode 100644 bits/zfs.nix create mode 100644 profiles/amdgpu/default.nix create mode 100644 profiles/default.nix create mode 100644 profiles/foldingathome/default.nix create mode 100644 profiles/home/default.nix create mode 100644 profiles/ipfs/default.nix create mode 100644 profiles/zfs/default.nix diff --git a/bits/amdgpu.nix b/bits/amdgpu.nix deleted file mode 100644 index c08540d..0000000 --- a/bits/amdgpu.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ configs, pkgs, libs, ... }: - -{ - boot.initrd.kernelModules = [ "amdgpu" ]; - services.xserver.videoDrivers = [ "amdgpu" ]; - hardware.opengl.driSupport = true; - hardware.opengl.extraPackages = with pkgs; [ - rocm-opencl-icd - rocm-opencl-runtime - amdvlk - ]; - hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ amdvlk ]; - - nixpkgs.config.packageOverrides = pkgs: { - fahclient = pkgs.fahclient.override { - extraPkgs = with pkgs; [ rocm-opencl-icd rocm-opencl-runtime ]; - }; - }; -} diff --git a/bits/foldingathome.nix b/bits/foldingathome.nix deleted file mode 100644 index d5163ff..0000000 --- a/bits/foldingathome.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - services.foldingathome = { - enable = true; - user = "cipherrot"; - team = 265265; - extraArgs = [ - "--config" - (builtins.toFile "config.xml" '' - - - - - - - - - '') - ]; - }; -} diff --git a/bits/home-common.nix b/bits/home-common.nix deleted file mode 100644 index b504a78..0000000 --- a/bits/home-common.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - hardware.printers.ensurePrinters = let - commonOptions = { - PageSize = "A4"; - Duplex = "DuplexNoTumble"; - InputSlot = "Auto"; - }; - in [ - { - name = "Study-Laser"; - location = "Study"; - description = "Samsung CLX-6260 Laser"; - deviceUri = - "dnssd://Samsung%20laser%20printer%20(Study)._printer._tcp.local/"; - model = "samsung/CLX-6260.ppd"; - ppdOptions = commonOptions // { - ColorMode = "False"; - MediaType = "Plain"; - }; - } - { - name = "Study-Inkjet"; - location = "Study"; - description = "Epson XP-860 Inkjet"; - deviceUri = - "dnssd://EPSON%20XP-860%20Series._ipp._tcp.local/?uuid=cfe92100-67c4-11d4-a45f-44d244241018"; - model = - "epson-inkjet-printer-escpr/Epson-XP-860_Series-epson-escpr-en.ppd"; - ppdOptions = commonOptions // { MediaType = "PLAIN_NORMAL"; }; - } - ]; - services.printing = { - drivers = with pkgs; [ samsung-unified-linux-driver epson-escpr ]; - }; - users.groups.lp.members = [ "jez" "elly" ]; -} diff --git a/bits/ipfs.nix b/bits/ipfs.nix deleted file mode 100644 index a5c7b49..0000000 --- a/bits/ipfs.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - services.ipfs = { - enable = true; - autoMount = true; - user = "jez"; - group = "jez"; - dataDir = "/home/jez/.ipfs"; - }; - - environment.systemPackages = [ pkgs.ipfs-migrator ]; -} diff --git a/bits/zfs.nix b/bits/zfs.nix deleted file mode 100644 index 8f07d82..0000000 --- a/bits/zfs.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ configs, pkgs, lib, ... }: - -{ - boot.supportedFilesystems = [ "zfs" ]; - - services.zfs = { - trim.enable = true; - autoSnapshot = { - enable = true; - flags = "-k -p --utc"; - }; - autoScrub = { - enable = true; - interval = "monthly"; - }; - }; -} diff --git a/flake.nix b/flake.nix index 47bc4dd..bcfd552 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,7 @@ nixos.lib.nixosSystem { system = "x86_64-linux"; modules = [ + ./profiles ./configuration.nix (./hosts + "/${hostName}") (./secrets + "/${hostName}.nix") diff --git a/hosts/arianrhod/default.nix b/hosts/arianrhod/default.nix index b19de1d..d98c57a 100644 --- a/hosts/arianrhod/default.nix +++ b/hosts/arianrhod/default.nix @@ -1,7 +1,8 @@ { config, pkgs, lib, ... }: { - imports = [ ./hardware.nix ../../bits/home-common.nix ../../bits/zfs.nix ]; + imports = [ ./hardware.nix ]; + profiles = [ "home" "zfs" ]; networking.interfaces.enp0s25.useDHCP = true; networking.interfaces.wlp2s0.useDHCP = true; diff --git a/hosts/gwydion/default.nix b/hosts/gwydion/default.nix index ca1608d..0348256 100644 --- a/hosts/gwydion/default.nix +++ b/hosts/gwydion/default.nix @@ -1,14 +1,8 @@ { config, pkgs, lib, ... }: { - imports = [ - ./hardware.nix - - ../../bits/home-common.nix - ../../bits/zfs.nix - ../../bits/amdgpu.nix - ../../bits/foldingathome.nix - ]; + imports = [ ./hardware.nix ]; + profiles = [ "home" "zfs" "amdgpu" "foldingathome" ]; boot.loader = { efi = { diff --git a/profiles/amdgpu/default.nix b/profiles/amdgpu/default.nix new file mode 100644 index 0000000..b710b51 --- /dev/null +++ b/profiles/amdgpu/default.nix @@ -0,0 +1,23 @@ +{ config, pkgs, lib, ... }: + +with lib; +let activeProfiles = config.profiles; +in { + config = mkIf (elem "amdgpu" activeProfiles) { + boot.initrd.kernelModules = [ "amdgpu" ]; + services.xserver.videoDrivers = [ "amdgpu" ]; + hardware.opengl.driSupport = true; + hardware.opengl.extraPackages = with pkgs; [ + rocm-opencl-icd + rocm-opencl-runtime + amdvlk + ]; + hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ amdvlk ]; + + nixpkgs.config.packageOverrides = pkgs: { + fahclient = pkgs.fahclient.override { + extraPkgs = with pkgs; [ rocm-opencl-icd rocm-opencl-runtime ]; + }; + }; + }; +} diff --git a/profiles/default.nix b/profiles/default.nix new file mode 100644 index 0000000..f777239 --- /dev/null +++ b/profiles/default.nix @@ -0,0 +1,12 @@ +{ config, lib, pkgs, ... }: + +with lib; { + imports = mapAttrsToList (k: _: ./. + ("/" + k)) + (filterAttrs (_: v: v == "directory") (builtins.readDir ./.)); + + options.profiles = mkOption { + default = [ ]; + description = "List of configuration profiles to activate"; + type = types.listOf types.str; + }; +} diff --git a/profiles/foldingathome/default.nix b/profiles/foldingathome/default.nix new file mode 100644 index 0000000..eb64589 --- /dev/null +++ b/profiles/foldingathome/default.nix @@ -0,0 +1,26 @@ +{ config, pkgs, lib, ... }: + +with lib; +let activeProfiles = config.profiles; +in { + config = mkIf (elem "foldingathome" activeProfiles) { + services.foldingathome = { + enable = true; + user = "cipherrot"; + team = 265265; + extraArgs = [ + "--config" + (builtins.toFile "config.xml" '' + + + + + + + + + '') + ]; + }; + }; +} diff --git a/profiles/home/default.nix b/profiles/home/default.nix new file mode 100644 index 0000000..ae3ada6 --- /dev/null +++ b/profiles/home/default.nix @@ -0,0 +1,42 @@ +{ config, pkgs, lib, ... }: + +with lib; +let activeProfiles = config.profiles; +in { + config = mkIf (elem "home" activeProfiles) { + hardware.printers.ensurePrinters = let + commonOptions = { + PageSize = "A4"; + Duplex = "DuplexNoTumble"; + InputSlot = "Auto"; + }; + in [ + { + name = "Study-Laser"; + location = "Study"; + description = "Samsung CLX-6260 Laser"; + deviceUri = + "dnssd://Samsung%20laser%20printer%20(Study)._printer._tcp.local/"; + model = "samsung/CLX-6260.ppd"; + ppdOptions = commonOptions // { + ColorMode = "False"; + MediaType = "Plain"; + }; + } + { + name = "Study-Inkjet"; + location = "Study"; + description = "Epson XP-860 Inkjet"; + deviceUri = + "dnssd://EPSON%20XP-860%20Series._ipp._tcp.local/?uuid=cfe92100-67c4-11d4-a45f-44d244241018"; + model = + "epson-inkjet-printer-escpr/Epson-XP-860_Series-epson-escpr-en.ppd"; + ppdOptions = commonOptions // { MediaType = "PLAIN_NORMAL"; }; + } + ]; + services.printing = { + drivers = with pkgs; [ samsung-unified-linux-driver epson-escpr ]; + }; + users.groups.lp.members = [ "jez" "elly" ]; + }; +} diff --git a/profiles/ipfs/default.nix b/profiles/ipfs/default.nix new file mode 100644 index 0000000..16a8502 --- /dev/null +++ b/profiles/ipfs/default.nix @@ -0,0 +1,17 @@ +{ config, pkgs, lib, ... }: + +with lib; +let activeProfiles = config.profiles; +in { + config = mkIf (elem "ipfs" activeProfiles) { + services.ipfs = { + enable = true; + autoMount = true; + user = "jez"; + group = "jez"; + dataDir = "/home/jez/.ipfs"; + }; + + environment.systemPackages = [ pkgs.ipfs-migrator ]; + }; +} diff --git a/profiles/zfs/default.nix b/profiles/zfs/default.nix new file mode 100644 index 0000000..c32cc7a --- /dev/null +++ b/profiles/zfs/default.nix @@ -0,0 +1,21 @@ +{ config, pkgs, lib, ... }: + +with lib; +let activeProfiles = config.profiles; +in { + config = mkIf (elem "zfs" activeProfiles) { + boot.supportedFilesystems = [ "zfs" ]; + + services.zfs = { + trim.enable = true; + autoSnapshot = { + enable = true; + flags = "-k -p --utc"; + }; + autoScrub = { + enable = true; + interval = "monthly"; + }; + }; + }; +}