project-wide: Refactored profile system

This commit is contained in:
kat witch 2021-03-28 21:01:01 +01:00
parent dac56f7394
commit 219efa52ba
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72
46 changed files with 52 additions and 107 deletions

View file

@ -2,8 +2,9 @@ rec {
sources = import ./nix/sources.nix;
pkgs = import ./pkgs { inherit sources; };
witch = import ./lib/witch.nix { lib = pkgs.lib; };
profiles = witch.modList { modulesDir = ./profiles; defaultFile = "nixos.nix"; };
hosts = import ./lib/hosts.nix { inherit pkgs sources witch; };
hosts = import ./lib/hosts.nix { inherit pkgs sources witch profiles; };
inherit (pkgs) lib;

View file

@ -1,12 +1,6 @@
{ pkgs, config, lib, witch, ... }:
let
homeModules = witch.modList {
modulesDir = ./profiles;
defaultFile = "home.nix";
};
in {
imports = lib.attrValues homeModules
++ [ ./modules/home ./private/profile/home ];
{
imports = [ ./modules/home ./private/profile/home ];
}

View file

@ -1,8 +1,10 @@
{ config, pkgs, ... }:
{ config, pkgs, profiles, ... }:
{
imports = [
./hw.nix
# profiles
profiles.kat
# host-specific services
./postgres.nix
./virtualhosts.nix
@ -20,7 +22,6 @@
../../../services/matrix.nix
];
deploy.profiles = [ "kat" ];
deploy.ssh.host = "athame.kittywit.ch";
boot.loader.grub.enable = true;

View file

@ -1,8 +1,11 @@
{ config, pkgs, lib, sources, witch, ... }:
{ config, pkgs, lib, profiles, sources, witch, ... }:
{
imports = [
./hw.nix
profiles.gui
profiles.sway
profiles.kat
../../../services/zfs.nix
../../../services/nginx.nix
./thermal
@ -10,7 +13,6 @@
./torrenting.nix
];
deploy.profiles = [ "gui" "sway" "kat" "private" ];
deploy.groups = [ "gui" ];
deploy.ssh.host = "192.168.1.135";

View file

@ -1,9 +1,15 @@
{ config, pkgs, ... }:
{ config, pkgs, profiles, ... }:
{
imports = [ ./hw.nix ../../../services/zfs.nix ];
imports = [
./hw.nix
../../../services/zfs.nix
profiles.gui
profiles.sway
profiles.kat
profiles.laptop
];
deploy.profiles = [ "gui" "sway" "kat" "laptop" "private" ];
deploy.groups = [ "gui" ];
deploy.ssh.host = "192.168.1.92";

View file

@ -1,5 +1,4 @@
{ pkgs, hostsDir ? ../hosts, privateHostsDir ? ../private/hosts
, commonImports ? [ ../nixos.nix ../modules/nixos ], pkgsPath ? ../pkgs
{ pkgs, hostsDir ? ../hosts, profiles, pkgsPath ? ../pkgs
, sources ? { }, witch ? { } }:
with pkgs.lib;
@ -12,10 +11,10 @@ rec {
{ config, ... }: {
_module.args = { inherit hosts groups; };
imports = [
(import (hostsDir + "/${hostName}/nixos"))
(import (privateHostsDir + "/${hostName}/nixos"))
../nixos.nix
../modules/nixos
../modules/nixos/deploy
] ++ commonImports;
];
networking = { inherit hostName; };
nixpkgs.pkgs = import pkgsPath {
inherit (config.nixpkgs) config;
@ -32,7 +31,7 @@ rec {
else
{ })
];
specialArgs = { inherit sources witch hostName; };
specialArgs = { inherit sources profiles witch hostName; };
})) hostNames);
groupNames = unique (concatLists

View file

@ -38,10 +38,6 @@ in {
type = types.bool;
default = true;
};
profiles = mkOption {
type = with types; listOf str;
default = [ ];
};
groups = mkOption {
type = with types; listOf str;
default = [ ];
@ -50,9 +46,6 @@ in {
};
config = mkIf cfg.enable {
deploy.profile = mkMerge (map (prof: {
${if options ? deploy.profile.${prof} then prof else null} = true;
}) config.deploy.profiles);
deploy.groups = [ "all" ];
system.build.deployScript = ''

View file

@ -1,13 +1,13 @@
{ pkgs, config, lib, sources, witch, options, hostName, ... }:
let
nixosModules = witch.modList {
modulesDir = ./profiles;
defaultFile = "nixos.nix";
};
in {
{
imports = lib.attrValues nixosModules ++ [ ./private/profile/nixos ];
imports = [
(import (./hosts + "/${hostName}/nixos"))
(import (./private/hosts + "/${hostName}/nixos"))
./profiles/common/nixos.nix
./private/profile/nixos
];
options.home-manager.users = lib.mkOption {
type = lib.types.attrsOf (lib.types.submoduleWith {
@ -21,7 +21,6 @@ in {
};
config = {
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
@ -29,10 +28,6 @@ in {
users = {
kat = {
imports = [ ./home.nix (import (./hosts + "/${hostName}/home")) ];
deploy.profile = lib.mkMerge (map (prof: {
${if options ? deploy.profile.${prof} then prof else null} = true;
}) config.deploy.profiles);
};
};
};

View file

@ -2,4 +2,6 @@
{
imports = [ ./nixos ];
config = { home-manager.users.kat = { imports = [ ./home.nix ]; }; };
}

View file

@ -3,5 +3,5 @@
{
imports = [ ./home ];
options = { deploy.profile.gui = lib.mkEnableOption "graphical system"; };
options = { deploy.profile.gui = lib.mkEnableOption "graphical system" // { default = true; }; };
}

View file

@ -1,7 +1,6 @@
{ config, lib, pkgs, ... }:
{
config = lib.mkIf config.deploy.profile.gui {
programs.notmuch = {
enable = true;
hooks = { preNew = "mbsync --all"; };
@ -32,5 +31,4 @@
};
};
programs.vim.plugins = [ pkgs.arc.pkgs.vimPlugins.notmuch-vim ];
};
}

View file

@ -12,7 +12,6 @@ let
"https://sync.kittywit.ch/token/1.0/sync/1.5";
};
in {
config = lib.mkIf config.deploy.profile.gui {
programs.zsh.shellAliases = {
ff-pm = "firefox --ProfileManager";
ff-main = "firefox -P main";
@ -68,5 +67,4 @@ in {
};
home.file.".config/tridactyl/tridactylrc".source = ./tridactylrc;
};
}

View file

@ -1,7 +1,6 @@
{ config, lib, pkgs, sources, ... }:
{
config = lib.mkIf config.deploy.profile.gui {
home.sessionVariables = {
SSH_AUTH_SOCK =
"\${SSH_AUTH_SOCK:-$(${pkgs.gnupg}/bin/gpgconf --list-dirs agent-ssh-socket)}";
@ -19,5 +18,4 @@
"no-allow-external-cache"
];
};
};
}

View file

@ -1,7 +1,6 @@
{ config, lib, pkgs, ... }:
{
config = lib.mkIf config.deploy.profile.gui {
gtk = {
enable = true;
iconTheme = {
@ -13,5 +12,4 @@
package = pkgs.arc-theme;
};
};
};
}

View file

@ -1,7 +1,6 @@
{ config, lib, pkgs, witch, ... }:
{
config = lib.mkIf config.deploy.profile.gui {
programs.kitty = {
enable = true;
font.name = witch.style.font.name;
@ -21,5 +20,4 @@
# inactive_tab_foreground = "#665577";
}; # // witch.style.base16;
};
};
}

View file

@ -1,7 +1,6 @@
{ config, lib, ... }:
{
config = lib.mkIf config.deploy.profile.gui {
programs.mpv = {
enable = true;
config = {
@ -11,5 +10,4 @@
hwdec = "auto";
};
};
};
}

View file

@ -1,7 +1,6 @@
{ config, lib, pkgs, witch, ... }:
{
config = lib.mkIf config.deploy.profile.gui {
programs.ncmpcpp = {
enable = true;
mpdMusicDir = "/home/kat/media-share/music";
@ -98,5 +97,4 @@
}
'';
};
};
}

View file

@ -6,7 +6,6 @@ let
../../../private/files/bitw/master.gpg
} "$@"'';
in {
config = lib.mkIf config.deploy.profile.gui {
home.packages = with pkgs; [
_1password
bitwarden
@ -62,5 +61,4 @@ in {
neofetch
htop
];
};
}

View file

@ -1,7 +1,6 @@
{ config, pkgs, lib, superConfig, ... }:
{
config = lib.mkIf config.deploy.profile.gui {
home.file = {
".local/share/weechat/sec.conf" = lib.mkIf config.deploy.profile.private {
source = "${../../../private/files/weechat/sec.conf}";
@ -104,5 +103,4 @@
};
};
};
};
}

View file

@ -3,5 +3,7 @@
{
imports = [ ./nixos ];
options = { deploy.profile.gui = lib.mkEnableOption "graphical system"; };
options = { deploy.profile.gui = lib.mkEnableOption "graphical system" // { default = true; }; };
config = { home-manager.users.kat = { imports = [ ./home.nix ]; }; };
}

View file

@ -1,5 +1,4 @@
{ config, lib, pkgs, ... }: {
config = lib.mkIf config.deploy.profile.gui {
networking = {
# networkmanager.enable = true;
resolvconf.useLocalResolver = true;
@ -39,5 +38,4 @@
systemd.services.dnscrypt-proxy2.serviceConfig = {
StateDirectory = "dnscrypt-proxy2";
};
};
}

View file

@ -1,7 +1,6 @@
{ config, pkgs, lib, witch, ... }:
{
config = lib.mkIf config.deploy.profile.gui {
xdg = {
portal = {
enable = true;
@ -12,5 +11,4 @@
gtkUsePortal = true;
};
};
};
}

View file

@ -1,7 +1,6 @@
{ config, pkgs, lib, ... }:
{
config = lib.mkIf config.deploy.profile.gui {
fonts.fontconfig.enable = true;
fonts.fonts = with pkgs; [
font-awesome
@ -9,5 +8,4 @@
iosevka
emacs-all-the-icons-fonts
];
};
}

View file

@ -1,7 +1,6 @@
{ config, pkgs, lib, ... }:
{
config = lib.mkIf config.deploy.profile.gui {
services.pcscd.enable = true;
services.udev.packages = [ pkgs.yubikey-personalization ];
@ -10,5 +9,4 @@
enableSSHSupport = true;
pinentryFlavor = "gtk2";
};
};
}

View file

@ -25,7 +25,6 @@ let
" ${c1} .:::: :::: ${c2}'::::. "
];
in {
config = lib.mkIf config.deploy.profile.gui {
services.mingetty = {
greetingLine = ''
\e[H\e[2J
@ -33,5 +32,4 @@ in {
+ "\\e[1;32m>>> NixOS ${config.system.nixos.label} (Linux \\r) - \\l\\e[0m";
helpLine = lib.mkForce "";
};
};
}

View file

@ -1,7 +1,6 @@
{ config, lib, pkgs, ... }:
{
config = lib.mkIf config.deploy.profile.gui {
sound = {
enable = true;
extraConfig = ''
@ -21,5 +20,4 @@
default-sample-channels = 2;
};
};
};
}

View file

@ -8,5 +8,5 @@
# imports = [ ../../../modules/home ];
#};
options = { deploy.profile.kat = lib.mkEnableOption "uhh meow"; };
options = { deploy.profile.kat = lib.mkEnableOption "uhh meow" // { default = true; };};
}

View file

@ -1,7 +1,6 @@
{ config, ... }:
{
config = lib.mkIf config.deploy.profile.kat {
base16 = {
shell.enable = true;
schemes = [ "rebecca.rebecca" ];
@ -10,5 +9,4 @@
# enable = true;
# defaultTheme = "rebecca.rebecca";
# };
};
}

View file

@ -1,7 +1,6 @@
{ config, pkgs, lib, ... }:
{
config = lib.mkIf config.deploy.profile.kat {
home.packages = with pkgs; [
git-crypt
gitAndTools.gitRemoteGcrypt
@ -28,5 +27,4 @@
signByDefault = true;
};
};
};
}

View file

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }:
{
config = lib.mkIf config.deploy.profile.kat {
home.packages = with pkgs; [ kitty.terminfo hyperfine hexyl tokei ];
};
}

View file

@ -1,7 +1,6 @@
{ config, pkgs, lib, ... }:
{
config = lib.mkIf config.deploy.profile.kat {
programs.ssh = {
enable = true;
controlMaster = "auto";
@ -23,5 +22,4 @@
"boline" = { hostname = "boline.kittywit.ch"; } // common;
};
};
};
}

View file

@ -1,7 +1,6 @@
{ config, lib, pkgs, ... }:
{
config = lib.mkIf config.deploy.profile.kat {
programs.zsh.shellAliases = {
tne = "tmux new -s";
tat = "tmux attach -t";
@ -53,5 +52,4 @@
set -g mouse on
'';
};
};
}

View file

@ -1,7 +1,6 @@
{ config, lib, pkgs, witch, ... }:
{
config = lib.mkIf config.deploy.profile.kat {
home.sessionVariables.EDITOR = "vim";
programs.vim = {
enable = true;
@ -35,5 +34,4 @@
xdg.configFile = {
"vim/coc-settings.json".text = builtins.readFile ./coc-settings.json;
};
};
}

View file

@ -1,7 +1,6 @@
{ config, lib, ... }:
{
config = lib.mkIf config.deploy.profile.kat {
xdg = {
enable = true;
userDirs = {
@ -16,5 +15,4 @@
music = "$HOME/media-share/music";
};
};
};
}

View file

@ -1,7 +1,6 @@
{ config, lib, pkgs, ... }:
{
config = lib.mkIf config.deploy.profile.kat {
xdg.dataFile = { "z/.keep".text = ""; };
home.packages = with pkgs; [ fzf fd ];
programs.zsh = {
@ -59,5 +58,4 @@
enableZshIntegration = true;
enableNixDirenvIntegration = true;
};
};
}

View file

@ -1,7 +1,9 @@
{ config, pkgs, lib, ... }:
{
config = lib.mkIf config.deploy.profile.kat {
config = {
home-manager.users.kat = { imports = [ ./home.nix ]; };
users.users.kat = {
uid = 1000;
isNormalUser = true;
@ -15,5 +17,6 @@
};
};
options = { deploy.profile.kat = lib.mkEnableOption "uhh meow"; };
options = { deploy.profile.kat = lib.mkEnableOption "uhh meow" // { default = true; }; };
}

View file

@ -1,5 +1,5 @@
{ lib, ... }:
{
options = { deploy.profile.laptop = lib.mkEnableOption "lappytop"; };
options = { deploy.profile.laptop = lib.mkEnableOption "lappytop" // { default = true; }; };
}

View file

@ -3,5 +3,7 @@
{
imports = [ ./nixos ];
options = { deploy.profile.laptop = lib.mkEnableOption "lappytop"; };
options = { deploy.profile.laptop = lib.mkEnableOption "lappytop" // { default = true; }; };
config = { home-manager.users.kat = { imports = [ ./home.nix ]; }; };
}

View file

@ -1,5 +1,4 @@
{ config, lib, pkgs, ... }:
{
config = lib.mkIf config.deploy.profile.laptop { };
}

View file

@ -3,5 +3,5 @@
{
imports = [ ./home ];
options = { deploy.profile.sway = lib.mkEnableOption "sway wm"; };
options = { deploy.profile.sway = lib.mkEnableOption "sway wm" // { default = true; }; };
}

View file

@ -1,11 +1,9 @@
{ config, lib, ... }:
{
config = lib.mkIf config.deploy.profile.sway {
services.gammastep = {
enable = true;
latitude = "51.5074";
longitude = "0.1278";
};
};
}

View file

@ -1,7 +1,6 @@
{ config, pkgs, lib, witch, ... }:
{
config = lib.mkIf config.deploy.profile.sway {
systemd.user.services = {
mako = {
Unit = {
@ -24,5 +23,4 @@
backgroundColor = "${witch.style.base16.color0}70";
textColor = witch.style.base16.color7;
};
};
}

View file

@ -1,7 +1,6 @@
{ config, pkgs, lib, witch, ... }:
{
config = lib.mkIf config.deploy.profile.sway {
home.sessionVariables = {
MOZ_ENABLE_WAYLAND = 1;
XDG_CURRENT_DESKTOP = "sway";
@ -265,6 +264,5 @@
${workspaceBindingsStr}
'';
};
};
}

View file

@ -1,7 +1,6 @@
{ config, pkgs, lib, ... }:
{
config = lib.mkIf config.deploy.profile.sway {
systemd.user.services.swayidle = {
Unit = {
Description = "swayidle";
@ -34,5 +33,4 @@
};
Install = { WantedBy = [ "sway-session.target" ]; };
};
};
}

View file

@ -3,5 +3,7 @@
{
imports = [ ./nixos ];
options = { deploy.profile.sway = lib.mkEnableOption "sway wm"; };
options = { deploy.profile.sway = lib.mkEnableOption "sway wm" // { default = true; }; };
config = { home-manager.users.kat = { imports = [ ./home.nix ]; }; };
}

View file

@ -1,10 +1,8 @@
{ config, pkgs, lib, sources, ... }:
{
config = lib.mkIf config.deploy.profile.sway {
programs.sway = {
enable = true;
extraPackages = with pkgs; lib.mkForce [ xwayland swaylock swayidle ];
};
};
}