diff --git a/.gitignore b/.gitignore index 1a3a7ad7..af0bd12e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /result -secrets.nix \ No newline at end of file +secrets.nix +!config/profiles/common/nixos/secrets.nix \ No newline at end of file diff --git a/config/common/default.nix b/config/common/default.nix deleted file mode 100644 index 2f8ce0a6..00000000 --- a/config/common/default.nix +++ /dev/null @@ -1,92 +0,0 @@ -{ config, lib, pkgs, sources, ... }: - -{ - imports = [ - ../users - (sources.home-manager + "/nixos") - ]; - - boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; - boot.loader.grub.configurationLimit = 8; - boot.loader.systemd-boot.configurationLimit = 8; - - nixpkgs.config = { allowUnfree = true; }; - nix = { - nixPath = [ - "nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos" - "nixpkgs-unstable=${sources.nixpkgs-unstable}" - "nixpkgs-mozilla=${sources.nixpkgs-mozilla}" - "NUR=${sources.NUR}" - "arc=${sources.arc-nixexprs}" - ]; - binaryCaches = [ "https://arc.cachix.org" ]; - binaryCachePublicKeys = - [ "arc.cachix.org-1:DZmhclLkB6UO0rc0rBzNpwFbbaeLfyn+fYccuAy7YVY=" ]; - gc.automatic = lib.mkDefault true; - gc.options = lib.mkDefault "--delete-older-than 1w"; - trustedUsers = [ "root" "@wheel" ]; - }; - - secrets = { - root = "/var/lib/kat/secrets"; - persistentRoot = "/var/lib/kat/secrets"; - external = true; - }; - - services.journald.extraConfig = "SystemMaxUse=512M"; - - environment.variables = { - EDITOR = "emacs"; - TERMINFO_DIRS = "${pkgs.kitty.terminfo.outPath}/share/terminfo"; - }; - - services.openssh = { - enable = true; - ports = lib.mkDefault [ 62954 ]; - passwordAuthentication = false; - challengeResponseAuthentication = false; - permitRootLogin = lib.mkDefault "prohibit-password"; - kexAlgorithms = [ "curve25519-sha256@libssh.org" ]; - extraConfig = '' - StreamLocalBindUnlink yes - LogLevel VERBOSE - ''; - }; - security.sudo.wheelNeedsPassword = lib.mkForce false; - - i18n.defaultLocale = "en_GB.UTF-8"; - time.timeZone = "Europe/London"; - console = { - font = "Lat2-Terminus16"; - keyMap = "uk"; - }; - - services.tailscale.enable = true; - - environment.systemPackages = with pkgs; [ - smartmontools - hddtemp - lm_sensors - htop - cachix - ripgrep - git - kitty.terminfo - nixfmt - mprime - wget - rsync - pv - pinentry-curses - progress - bc - zstd - file - whois - fd - exa - socat - tmux - gnupg - ]; -} diff --git a/config/home.nix b/config/home.nix new file mode 100644 index 00000000..699f0261 --- /dev/null +++ b/config/home.nix @@ -0,0 +1,10 @@ +{ pkgs, config, lib, witch, ... }: +let + homeModules = witch.modList { + modulesDir = ./profiles; + defaultFile = "home.nix"; + }; +in { + + imports = lib.attrValues homeModules ++ [ ../modules/home ]; +} diff --git a/config/hosts/athame/configuration.nix b/config/hosts/athame/configuration.nix index e052ad39..d1b9200c 100644 --- a/config/hosts/athame/configuration.nix +++ b/config/hosts/athame/configuration.nix @@ -23,7 +23,7 @@ ./matrix.nix ]; - deploy.profiles = [ ]; + deploy.profiles = [ "kat" ]; deploy.ssh.host = "athame.kittywit.ch"; boot.loader.grub.enable = true; diff --git a/config/hosts/boline/configuration.nix b/config/hosts/boline/configuration.nix index 2a849bc6..9c85fa7e 100644 --- a/config/hosts/boline/configuration.nix +++ b/config/hosts/boline/configuration.nix @@ -6,7 +6,7 @@ #./wireguard.nix ]; - deploy.profiles = [ ]; + deploy.profiles = [ "kat" ]; deploy.ssh.host = "boline.kittywit.ch"; boot.loader.grub.enable = true; diff --git a/config/hosts/samhain/configuration.nix b/config/hosts/samhain/configuration.nix index 2a03870d..7df33dd0 100644 --- a/config/hosts/samhain/configuration.nix +++ b/config/hosts/samhain/configuration.nix @@ -9,7 +9,7 @@ ./torrenting.nix ]; - deploy.profiles = [ "desktop" "development" "sway" "gaming" "network" ]; + deploy.profiles = [ "gui" "sway" "kat" ]; deploy.ssh.host = "192.168.1.135"; # libvirtd is used for our virtual machine diff --git a/config/hosts/samhain/screenstub.yml b/config/hosts/samhain/screenstub.yml index e6eea2d5..332cd22b 100644 --- a/config/hosts/samhain/screenstub.yml +++ b/config/hosts/samhain/screenstub.yml @@ -29,7 +29,7 @@ qemu: #routing: qmp # (default) does not require extra configuration or dependencies #routing: spice # no external requirements # CURRENTLY UNIMPLEMENTED #routing: input-linux # requires uinput - #routing: virtio-host # requires uinput, recommended for performance, requires vioinput drivers in guest + routing: virtio-host # requires uinput, recommended for performance, requires vioinput drivers in guest #driver: ps2 # use PS/2 in the guest for all input devices (absolute mouse mode unsupported) #driver: usb # use USB keyboard/mouse/tablet in the guest #driver: virtio # Recommended but vioinput drivers must be installed in guest @@ -39,7 +39,7 @@ qemu: #driver: virtio #relative_driver: virtio qmp_socket: /tmp/vfio-qmp # path to QMP socket - #ga_socket: /tmp/vfio-qga # path to Guest Agent socket + ga_socket: /tmp/vfio-qga # path to Guest Agent socket key_remap: # Arbitrary keys can be remapped in the guest # See https://docs.rs/input-linux/*/input_linux/enum.Key.html for a list of key names available (mouse buttons can also be used) @@ -47,12 +47,6 @@ key_remap: # Arbitrary keys can be remapped in the guest RightAlt: LeftMeta # remap right alt to trigger the windows key hotkeys: # Trigger various events on key combinations -- triggers: [G] - modifiers: [LeftMeta] - on_release: false # trigger on downpress of key - global: false # optionally trigger even when not in focus # CURRENTLY UNIMPLEMENTED - events: # Select which events to trigger with this hotkey - - toggle_grab: xcore # Standard Xorg window grab #- toggle_grab:y # xdevice: # CURRENTLY UNIMPLEMENTED # devices: # Only grab specific devices from Xorg @@ -65,10 +59,12 @@ hotkeys: # Trigger various events on key combinations #- shutdown # safely shuts the guest system down #- reboot # reboots the guest #- exit # quits screenstub -- triggers: [Y] +- triggers: [G] modifiers: [LeftMeta] events: - - toggle_grab: xcore # Confine input/mouse to window + - toggle_grab: + x: + mouse: false # Confine input/mouse to window - toggle_grab: evdev: # evdev grab is useful for playing games that don't work with absolute mouse events exclusive: false # grab exclusive access from the device(s) diff --git a/config/hosts/yule/configuration.nix b/config/hosts/yule/configuration.nix index cab5d24b..c38ded29 100644 --- a/config/hosts/yule/configuration.nix +++ b/config/hosts/yule/configuration.nix @@ -3,7 +3,7 @@ { imports = [ ./hardware.nix ../../services/zfs.nix ]; - deploy.profiles = [ "desktop" "development" "sway" "gaming" "network" ]; + deploy.profiles = [ "gui" "sway" "kat" "laptop" ]; deploy.ssh.host = "192.168.1.92"; boot.loader.systemd-boot.enable = true; diff --git a/config/nixos.nix b/config/nixos.nix new file mode 100644 index 00000000..f5fdb169 --- /dev/null +++ b/config/nixos.nix @@ -0,0 +1,39 @@ +{ pkgs, config, lib, sources, witch, options, ... }: + +let + nixosModules = witch.modList { + modulesDir = ./profiles; + defaultFile = "nixos.nix"; + }; +in { + + imports = lib.attrValues nixosModules; + + options.home-manager.users = lib.mkOption { + type = lib.types.attrsOf (lib.types.submoduleWith { + modules = [ ]; + specialArgs = { + inherit sources witch; + superConfig = config; + }; + }); + }; + + config = { + + home-manager = { + useUserPackages = true; + useGlobalPkgs = true; + + users = { + kat = { + imports = [ ./home.nix ]; + + deploy.profile = lib.mkMerge (map (prof: { + ${if options ? deploy.profile.${prof} then prof else null} = true; + }) config.deploy.profiles); + }; + }; + }; + }; +} diff --git a/config/profiles/common/home.nix b/config/profiles/common/home.nix new file mode 100644 index 00000000..5bd3e36b --- /dev/null +++ b/config/profiles/common/home.nix @@ -0,0 +1,3 @@ +{ ... }: + +{ } diff --git a/config/profiles/common/nixos.nix b/config/profiles/common/nixos.nix new file mode 100644 index 00000000..2f8f08e5 --- /dev/null +++ b/config/profiles/common/nixos.nix @@ -0,0 +1,5 @@ +{ config, lib, pkgs, sources, ... }: + +{ + imports = [ ./nixos ]; +} diff --git a/config/users/default.nix b/config/profiles/common/nixos/access.nix similarity index 74% rename from config/users/default.nix rename to config/profiles/common/nixos/access.nix index b0c00c45..d7ce38d5 100644 --- a/config/users/default.nix +++ b/config/profiles/common/nixos/access.nix @@ -1,9 +1,7 @@ -{ pkgs, config, ... }: +{ config, lib, pkgs, sources, ... }: { - imports = [ - ./kat - ]; + security.sudo.wheelNeedsPassword = lib.mkForce false; users.users.root = { openssh.authorizedKeys.keys = with pkgs.lib; diff --git a/config/profiles/common/nixos/default.nix b/config/profiles/common/nixos/default.nix new file mode 100644 index 00000000..3cc37fc5 --- /dev/null +++ b/config/profiles/common/nixos/default.nix @@ -0,0 +1,14 @@ +{ config, lib, pkgs, sources, ... }: + +{ + imports = [ + ./system.nix + ./net.nix + ./access.nix + ./locale.nix + ./nix.nix + ./ssh.nix + ./packages.nix + ./secrets.nix + ]; +} diff --git a/config/profiles/common/nixos/locale.nix b/config/profiles/common/nixos/locale.nix new file mode 100644 index 00000000..2f98e850 --- /dev/null +++ b/config/profiles/common/nixos/locale.nix @@ -0,0 +1,10 @@ +{ config, lib, pkgs, sources, ... }: + +{ + i18n.defaultLocale = "en_GB.UTF-8"; + time.timeZone = "Europe/London"; + console = { + font = "Lat2-Terminus16"; + keyMap = "uk"; + }; +} diff --git a/config/profiles/common/nixos/net.nix b/config/profiles/common/nixos/net.nix new file mode 100644 index 00000000..8188cde8 --- /dev/null +++ b/config/profiles/common/nixos/net.nix @@ -0,0 +1,5 @@ +{ config, lib, pkgs, sources, ... }: + +{ + services.tailscale.enable = true; +} diff --git a/config/profiles/common/nixos/nix.nix b/config/profiles/common/nixos/nix.nix new file mode 100644 index 00000000..1f02e8ec --- /dev/null +++ b/config/profiles/common/nixos/nix.nix @@ -0,0 +1,23 @@ +{ config, lib, pkgs, sources, ... }: + +{ + boot.loader.grub.configurationLimit = 8; + boot.loader.systemd-boot.configurationLimit = 8; + + nixpkgs.config = { allowUnfree = true; }; + nix = { + nixPath = [ + "nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos" + "nixpkgs-unstable=${sources.nixpkgs-unstable}" + "nixpkgs-mozilla=${sources.nixpkgs-mozilla}" + "NUR=${sources.NUR}" + "arc=${sources.arc-nixexprs}" + ]; + binaryCaches = [ "https://arc.cachix.org" ]; + binaryCachePublicKeys = + [ "arc.cachix.org-1:DZmhclLkB6UO0rc0rBzNpwFbbaeLfyn+fYccuAy7YVY=" ]; + gc.automatic = lib.mkDefault true; + gc.options = lib.mkDefault "--delete-older-than 1w"; + trustedUsers = [ "root" "@wheel" ]; + }; +} diff --git a/config/profiles/common/nixos/packages.nix b/config/profiles/common/nixos/packages.nix new file mode 100644 index 00000000..c6537757 --- /dev/null +++ b/config/profiles/common/nixos/packages.nix @@ -0,0 +1,30 @@ +{ config, lib, pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + smartmontools + hddtemp + lm_sensors + htop + cachix + ripgrep + git + kitty.terminfo + nixfmt + mprime + wget + rsync + pv + pinentry-curses + progress + bc + zstd + file + whois + fd + exa + socat + tmux + gnupg + ]; +} diff --git a/config/profiles/common/nixos/secrets.nix b/config/profiles/common/nixos/secrets.nix new file mode 100644 index 00000000..877d1874 --- /dev/null +++ b/config/profiles/common/nixos/secrets.nix @@ -0,0 +1,9 @@ +{ config, lib, pkgs, ... }: + +{ + secrets = { + root = "/var/lib/kat/secrets"; + persistentRoot = "/var/lib/kat/secrets"; + external = true; + }; +} diff --git a/config/profiles/common/nixos/ssh.nix b/config/profiles/common/nixos/ssh.nix new file mode 100644 index 00000000..5178b613 --- /dev/null +++ b/config/profiles/common/nixos/ssh.nix @@ -0,0 +1,16 @@ +{ config, lib, pkgs, ... }: + +{ + services.openssh = { + enable = true; + ports = lib.mkDefault [ 62954 ]; + passwordAuthentication = false; + challengeResponseAuthentication = false; + permitRootLogin = lib.mkDefault "prohibit-password"; + kexAlgorithms = [ "curve25519-sha256@libssh.org" ]; + extraConfig = '' + StreamLocalBindUnlink yes + LogLevel VERBOSE + ''; + }; +} diff --git a/config/profiles/common/nixos/system.nix b/config/profiles/common/nixos/system.nix new file mode 100644 index 00000000..a4435623 --- /dev/null +++ b/config/profiles/common/nixos/system.nix @@ -0,0 +1,8 @@ +{ config, lib, pkgs, sources, ... }: + +{ + #imports = [ (sources.home-manager + "/nixos") ]; + + boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; + services.journald.extraConfig = "SystemMaxUse=512M"; +} diff --git a/config/profiles/gui/home.nix b/config/profiles/gui/home.nix new file mode 100644 index 00000000..18d2b645 --- /dev/null +++ b/config/profiles/gui/home.nix @@ -0,0 +1,7 @@ +{ lib, ... }: + +{ + imports = [ ./home ]; + + options = { deploy.profile.gui = lib.mkEnableOption "graphical system"; }; +} diff --git a/config/profiles/gui/home/default.nix b/config/profiles/gui/home/default.nix new file mode 100644 index 00000000..d9ce4c03 --- /dev/null +++ b/config/profiles/gui/home/default.nix @@ -0,0 +1,12 @@ +{ ... }: + +{ + imports = [ + ./firefox + ./kitty.nix + ./packages.nix + ./nextcloud.nix + ./gpg.nix + ./gtk.nix + ]; +} diff --git a/config/users/kat/firefox/default.nix b/config/profiles/gui/home/firefox/default.nix similarity index 90% rename from config/users/kat/firefox/default.nix rename to config/profiles/gui/home/firefox/default.nix index c4907f5c..9be24475 100644 --- a/config/users/kat/firefox/default.nix +++ b/config/profiles/gui/home/firefox/default.nix @@ -1,10 +1,9 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, sources, superConfig, ... }: let - sources = import ../../../../nix/sources.nix; commonSettings = { "app.update.auto" = false; - "identity.fxaccounts.account.device.name" = config.networking.hostName; + "identity.fxaccounts.account.device.name" = superConfig.networking.hostName; "signon.rememberSignons" = false; "browser.urlbar.placeholderName" = "DuckDuckGo"; "toolkit.legacyUserProfileCustomizations.stylesheets" = true; @@ -12,7 +11,7 @@ let "https://sync.kittywit.ch/token/1.0/sync/1.5"; }; in { - home-manager.users.kat = { + config = lib.mkIf config.deploy.profile.gui { programs.fish.shellAliases = { ff-pm = "firefox --ProfileManager"; ff-main = "firefox -P main"; diff --git a/config/users/kat/firefox/tridactylrc b/config/profiles/gui/home/firefox/tridactylrc similarity index 100% rename from config/users/kat/firefox/tridactylrc rename to config/profiles/gui/home/firefox/tridactylrc diff --git a/config/users/kat/firefox/userChrome.css.nix b/config/profiles/gui/home/firefox/userChrome.css.nix similarity index 100% rename from config/users/kat/firefox/userChrome.css.nix rename to config/profiles/gui/home/firefox/userChrome.css.nix diff --git a/config/profiles/gui/home/gpg.nix b/config/profiles/gui/home/gpg.nix new file mode 100644 index 00000000..23c647f0 --- /dev/null +++ b/config/profiles/gui/home/gpg.nix @@ -0,0 +1,10 @@ +{ config, lib, pkgs, sources, ... }: + +{ + config = lib.mkIf config.deploy.profile.gui { + home.file.".gnupg/gpg-agent.conf".text = '' + enable-ssh-support + pinentry-program ${pkgs.pinentry.gtk2}/bin/pinentry + ''; + }; +} diff --git a/config/profiles/gui/home/gtk.nix b/config/profiles/gui/home/gtk.nix new file mode 100644 index 00000000..965ebb1d --- /dev/null +++ b/config/profiles/gui/home/gtk.nix @@ -0,0 +1,17 @@ +{ config, lib, pkgs, ... }: + +{ + config = lib.mkIf config.deploy.profile.gui { + gtk = { + enable = true; + iconTheme = { + name = "Numix-Square"; + package = pkgs.numix-icon-theme-square; + }; + theme = { + name = "Arc-Dark"; + package = pkgs.arc-theme; + }; + }; + }; +} diff --git a/config/profiles/gui/home/kitty.nix b/config/profiles/gui/home/kitty.nix new file mode 100644 index 00000000..62588445 --- /dev/null +++ b/config/profiles/gui/home/kitty.nix @@ -0,0 +1,27 @@ +{ config, lib, pkgs, witch, ... }: + +{ + config = lib.mkIf config.deploy.profile.gui { + home.sessionVariables.TERMINFO_DIRS = + "${pkgs.kitty.terminfo.outPath}/share/terminfo"; + programs.kitty = { + enable = true; + font.name = witch.style.font.name; + settings = { + font_size = witch.style.font.size; + background = witch.style.base16.color0; + background_opacity = "0.7"; + foreground = witch.style.base16.color7; + selection_background = witch.style.base16.color7; + selection_foreground = witch.style.base16.color0; + url_color = witch.style.base16.color3; + cursor = witch.style.base16.color7; + active_border_color = "#75715e"; + active_tab_background = "#9900ff"; + active_tab_foreground = witch.style.base16.color7; + inactive_tab_background = "#3a3a3a"; + inactive_tab_foreground = "#665577"; + } // witch.style.base16; + }; + }; +} diff --git a/config/profiles/gui/home/nextcloud.nix b/config/profiles/gui/home/nextcloud.nix new file mode 100644 index 00000000..d48d385c --- /dev/null +++ b/config/profiles/gui/home/nextcloud.nix @@ -0,0 +1,7 @@ +{ config, lib, pkgs, ... }: + +{ + config = lib.mkIf config.deploy.profile.gui { + services.nextcloud-client.enable = true; + }; +} diff --git a/config/profiles/gui/home/packages.nix b/config/profiles/gui/home/packages.nix new file mode 100644 index 00000000..06e2f29f --- /dev/null +++ b/config/profiles/gui/home/packages.nix @@ -0,0 +1,47 @@ +{ config, lib, pkgs, ... }: + +{ + config = lib.mkIf config.deploy.profile.gui { + home.packages = with pkgs; [ + _1password + bitwarden + mpv + element-desktop + mumble + obs-studio + xfce.ristretto + audacity + avidemux + vlc + ffmpeg-full + thunderbird + unstable.syncplay + unstable.youtube-dl + unstable.google-chrome + v4l-utils + transmission-gtk + lm_sensors + baresip + psmisc + unstable.discord + tdesktop + yubikey-manager + pinentry.gtk2 + dino + libnotify + nextcloud-client + vegur + nitrogen + terminator + pavucontrol + gparted + scrot + gimp-with-plugins + vscode + cryptsetup + pcmanfm + neofetch + htop + ]; + }; +} diff --git a/config/profiles/gui/nixos.nix b/config/profiles/gui/nixos.nix new file mode 100644 index 00000000..4b278b87 --- /dev/null +++ b/config/profiles/gui/nixos.nix @@ -0,0 +1,7 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ ./nixos ]; + + options = { deploy.profile.gui = lib.mkEnableOption "graphical system"; }; +} diff --git a/config/profiles/gui/nixos/default.nix b/config/profiles/gui/nixos/default.nix new file mode 100644 index 00000000..9830562b --- /dev/null +++ b/config/profiles/gui/nixos/default.nix @@ -0,0 +1,13 @@ +{ ... }: + +{ + imports = [ + ./fonts.nix + ./gpg.nix + ./firefox.nix + ./dns.nix + ./nixpkgs.nix + ./mingetty.nix + ./sound.nix + ]; +} diff --git a/config/users/kat/network.nix b/config/profiles/gui/nixos/dns.nix similarity index 95% rename from config/users/kat/network.nix rename to config/profiles/gui/nixos/dns.nix index d7eec4c7..b4870bbe 100644 --- a/config/users/kat/network.nix +++ b/config/profiles/gui/nixos/dns.nix @@ -1,5 +1,5 @@ { config, lib, pkgs, ... }: { - config = lib.mkIf (lib.elem "network" config.deploy.profiles) { + config = lib.mkIf config.deploy.profile.gui { networking = { networkmanager.enable = true; resolvconf.useLocalResolver = true; diff --git a/config/profiles/gui/nixos/firefox.nix b/config/profiles/gui/nixos/firefox.nix new file mode 100644 index 00000000..8caba090 --- /dev/null +++ b/config/profiles/gui/nixos/firefox.nix @@ -0,0 +1,16 @@ +{ config, pkgs, lib, witch, ... }: + +{ + config = lib.mkIf config.deploy.profile.gui { + xdg = { + portal = { + enable = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-wlr + xdg-desktop-portal-gtk + ]; + gtkUsePortal = true; + }; + }; + }; +} diff --git a/config/profiles/gui/nixos/fonts.nix b/config/profiles/gui/nixos/fonts.nix new file mode 100644 index 00000000..bb72782e --- /dev/null +++ b/config/profiles/gui/nixos/fonts.nix @@ -0,0 +1,13 @@ +{ config, pkgs, lib, ... }: + +{ + config = lib.mkIf config.deploy.profile.gui { + fonts.fontconfig.enable = true; + fonts.fonts = with pkgs; [ + font-awesome + nerdfonts + iosevka + emacs-all-the-icons-fonts + ]; + }; +} diff --git a/config/profiles/gui/nixos/gpg.nix b/config/profiles/gui/nixos/gpg.nix new file mode 100644 index 00000000..8006e9de --- /dev/null +++ b/config/profiles/gui/nixos/gpg.nix @@ -0,0 +1,8 @@ +{ config, pkgs, lib, ... }: + +{ + config = lib.mkIf config.deploy.profile.gui { + services.pcscd.enable = true; + services.udev.packages = [ pkgs.yubikey-personalization ]; + }; +} diff --git a/config/profiles/gui/nixos/mingetty.nix b/config/profiles/gui/nixos/mingetty.nix new file mode 100644 index 00000000..74daf494 --- /dev/null +++ b/config/profiles/gui/nixos/mingetty.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, ... }: + +let + c1 = "\\e[22;34m"; + c2 = "\\e[1;35m"; + nixos_logo = [ + " ${c1} ::::. ${c2}'::::: ::::' " + " ${c1} '::::: ${c2}':::::. ::::' " + " ${c1} ::::: ${c2}'::::.::::: " + " ${c1} .......:::::..... ${c2}:::::::: " + " ${c1} ::::::::::::::::::. ${c2}:::::: ${c1}::::. " + " ${c1} ::::::::::::::::::::: ${c2}:::::. ${c1}.::::' " + " ${c2} ..... ::::' ${c1}:::::' " + " ${c2} ::::: '::' ${c1}:::::' " + " ${c2} ........::::: ' ${c1}:::::::::::. " + " ${c2}::::::::::::: ${c1}::::::::::::: " + " ${c2} ::::::::::: ${c1}.. ${c1}::::: " + " ${c2} .::::: ${c1}.::: ${c1}::::: " + " ${c2} .::::: ${c1}::::: ${c1}''''' ${c2}..... " + " ${c2} ::::: ${c1}':::::. ${c2}......:::::::::::::' " + " ${c2} ::: ${c1}::::::. ${c2}':::::::::::::::::' " + " ${c1} .:::::::: ${c2}':::::::::: " + " ${c1} .::::''::::. ${c2}'::::. " + " ${c1} .::::' ::::. ${c2}'::::. " + " ${c1} .:::: :::: ${c2}'::::. " + ]; +in { + config = lib.mkIf config.deploy.profile.gui { + services.mingetty = { + greetingLine = '' + \e[H\e[2J + \e[9;10]'' + lib.concatStringsSep "\n" nixos_logo + "\n\n" + + "\\e[1;32m>>> NixOS ${config.system.nixos.label} (Linux \\r) - \\l\\e[0m"; + helpLine = lib.mkForce ""; + }; + }; +} diff --git a/config/profiles/gui/nixos/nixpkgs.nix b/config/profiles/gui/nixos/nixpkgs.nix new file mode 100644 index 00000000..f93b7698 --- /dev/null +++ b/config/profiles/gui/nixos/nixpkgs.nix @@ -0,0 +1,9 @@ +{ pkgs, config, lib, ... }: + +{ + nixpkgs.config = { + allowUnfree = true; + mumble.speechdSupport = true; + pulseaudio = true; + }; +} diff --git a/config/profiles/gui/nixos/sound.nix b/config/profiles/gui/nixos/sound.nix new file mode 100644 index 00000000..4e1c2a81 --- /dev/null +++ b/config/profiles/gui/nixos/sound.nix @@ -0,0 +1,20 @@ +{ config, lib, pkgs, ... }: + +{ + config = lib.mkIf config.deploy.profile.gui { + sound = { + enable = true; + extraConfig = '' + defaults.pcm.rate_converter "speexrate_best" + ''; + }; + hardware.pulseaudio = { + enable = true; + daemon.config = { + default-sample-format = "s24le"; + default-sample-rate = 96000; + resample-method = "soxr-vhq"; + }; + }; + }; +} diff --git a/config/profiles/kat/home.nix b/config/profiles/kat/home.nix new file mode 100644 index 00000000..b9db2097 --- /dev/null +++ b/config/profiles/kat/home.nix @@ -0,0 +1,12 @@ +{ lib, ... }: + +{ + imports = [ ./home ]; + + #home-manager.useGlobalPkgs = true; + #home-manager.users.kat = { + # imports = [ ../../../modules/home ]; + #}; + + options = { deploy.profile.kat = lib.mkEnableOption "uhh meow"; }; +} diff --git a/config/profiles/kat/home/default.nix b/config/profiles/kat/home/default.nix new file mode 100644 index 00000000..2d4dbf56 --- /dev/null +++ b/config/profiles/kat/home/default.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + imports = [ ./shell.nix ./git.nix ./tmux.nix ./ssh.nix ./emacs ]; +} diff --git a/config/users/kat/emacs.nix b/config/profiles/kat/home/emacs/default.nix similarity index 69% rename from config/users/kat/emacs.nix rename to config/profiles/kat/home/emacs/default.nix index 619bb7a6..ac235780 100644 --- a/config/users/kat/emacs.nix +++ b/config/profiles/kat/home/emacs/default.nix @@ -1,6 +1,5 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, sources, ... }: let - sources = import ../../../nix/sources.nix; emacs = pkgs.callPackage sources.nix-doom-emacs { doomPrivateDir = "${./doom.d}"; emacsPackagesOverlay = self: super: { @@ -9,8 +8,9 @@ let }; }; in { - users.users.kat.packages = [ emacs ]; - home-manager.users.kat = { + config = lib.mkIf config.deploy.profile.kat { + home.sessionVariables.EDITOR = "emacs"; + home.packages = [ emacs ]; home.file.".emacs.d/init.el".text = '' (load "default.el") ''; diff --git a/config/users/kat/doom.d/config.el b/config/profiles/kat/home/emacs/doom.d/config.el similarity index 100% rename from config/users/kat/doom.d/config.el rename to config/profiles/kat/home/emacs/doom.d/config.el diff --git a/config/users/kat/doom.d/init.el b/config/profiles/kat/home/emacs/doom.d/init.el similarity index 100% rename from config/users/kat/doom.d/init.el rename to config/profiles/kat/home/emacs/doom.d/init.el diff --git a/config/users/kat/doom.d/packages.el b/config/profiles/kat/home/emacs/doom.d/packages.el similarity index 100% rename from config/users/kat/doom.d/packages.el rename to config/profiles/kat/home/emacs/doom.d/packages.el diff --git a/config/profiles/kat/home/git.nix b/config/profiles/kat/home/git.nix new file mode 100644 index 00000000..8f20ba43 --- /dev/null +++ b/config/profiles/kat/home/git.nix @@ -0,0 +1,19 @@ +{ config, pkgs, lib, ... }: + +{ + config = lib.mkIf config.deploy.profile.kat { + home.packages = with pkgs; [ git-crypt gitAndTools.gitRemoteGcrypt ]; + + programs.git = { + enable = true; + package = pkgs.gitAndTools.gitFull; + userName = "kat witch"; + userEmail = "kat@kittywit.ch"; + extraConfig = { protocol.gcrypt.allow = "always"; }; + signing = { + key = "01F50A29D4AA91175A11BDB17248991EFA8EFBEE"; + signByDefault = true; + }; + }; + }; +} diff --git a/config/users/kat/fish.nix b/config/profiles/kat/home/shell.nix similarity index 64% rename from config/users/kat/fish.nix rename to config/profiles/kat/home/shell.nix index 063d9a59..29fb3b75 100644 --- a/config/users/kat/fish.nix +++ b/config/profiles/kat/home/shell.nix @@ -1,11 +1,11 @@ { config, lib, pkgs, ... }: { - home-manager.users.kat = { + config = lib.mkIf config.deploy.profile.kat { programs.fish = { enable = true; interactiveShellInit = '' - ${if (lib.elem "desktop" config.deploy.groups) then + ${if (config.deploy.profile.gui) then "export SSH_AUTH_SOCK=(gpgconf --list-dirs agent-ssh-socket)" else ""} @@ -22,10 +22,15 @@ }; }]; }; - }; - programs.direnv = { - enable = true; - enableFishIntegration = true; - enableNixDirenvIntegration = true; + programs.starship = { + enable = true; + enableFishIntegration = true; + }; + programs.direnv = { + enable = true; + enableFishIntegration = true; + enableNixDirenvIntegration = true; + }; + programs.bat.enable = true; }; } diff --git a/config/users/kat/ssh.nix b/config/profiles/kat/home/ssh.nix similarity index 90% rename from config/users/kat/ssh.nix rename to config/profiles/kat/home/ssh.nix index f340ed5c..4ae60fbd 100644 --- a/config/users/kat/ssh.nix +++ b/config/profiles/kat/home/ssh.nix @@ -1,7 +1,7 @@ -{ configs, pkgs, ... }: +{ config, pkgs, lib, ... }: { - home-manager.users.kat = { + config = lib.mkIf config.deploy.profile.kat { programs.ssh = { enable = true; controlMaster = "auto"; diff --git a/config/profiles/kat/home/tmux.nix b/config/profiles/kat/home/tmux.nix new file mode 100644 index 00000000..319dd945 --- /dev/null +++ b/config/profiles/kat/home/tmux.nix @@ -0,0 +1,43 @@ +{ config, lib, pkgs, ... }: + +{ + config = lib.mkIf config.deploy.profile.kat { + programs.fish.shellAliases = { + tne = "tmux new -s"; + tat = "tmux attach -t"; + }; + programs.tmux = { + enable = true; + extraConfig = '' + + # modes + setw -g clock-mode-colour colour5 + setw -g mode-style 'fg=colour1 bg=colour18 bold' + + # panes + set -g pane-border-style 'fg=colour19 bg=colour0' + set -g pane-active-border-style 'bg=colour0 fg=colour9' + + # statusbar + set -g status-position bottom + set -g status-justify left + set -g status-style 'bg=colour18 fg=colour137 dim' + set -g status-left ''' + set -g status-right '#[fg=colour233,bg=colour19] %F #[fg=colour233,bg=colour8] %H:%M:%S %Z' + set -g status-right-length 50 + set -g status-left-length 20 + + setw -g window-status-current-style 'fg=colour1 bg=colour19 bold' + setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F ' + + setw -g window-status-style 'fg=colour9 bg=colour18' + setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F ' + + setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold' + + # messages + set -g message-style 'fg=colour232 bg=colour16 bold' + ''; + }; + }; +} diff --git a/config/profiles/kat/nixos.nix b/config/profiles/kat/nixos.nix new file mode 100644 index 00000000..212c8be0 --- /dev/null +++ b/config/profiles/kat/nixos.nix @@ -0,0 +1,17 @@ +{ config, pkgs, lib, ... }: + +{ + config = lib.mkIf config.deploy.profile.kat { + users.users.kat = { + uid = 1000; + isNormalUser = true; + openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCocjQqiDIvzq+Qu3jkf7FXw5piwtvZ1Mihw9cVjdVcsra3U2c9WYtYrA3rS50N3p00oUqQm9z1KUrvHzdE+03ZCrvaGdrtYVsaeoCuuvw7qxTQRbItTAEsfRcZLQ5c1v/57HNYNEsjVrt8VukMPRXWgl+lmzh37dd9w45cCY1QPi+JXQQ/4i9Vc3aWSe4X6PHOEMSBHxepnxm5VNHm4PObGcVbjBf0OkunMeztd1YYA9sEPyEK3b8IHxDl34e5t6NDLCIDz0N/UgzCxSxoz+YJ0feQuZtud/YLkuQcMxW2dSGvnJ0nYy7SA5DkW1oqcy6CGDndHl5StOlJ1IF9aGh0gGkx5SRrV7HOGvapR60RphKrR5zQbFFka99kvSQgOZqSB3CGDEQGHv8dXKXIFlzX78jjWDOBT67vA/M9BK9FS2iNnBF5x6shJ9SU5IK4ySxq8qvN7Us8emkN3pyO8yqgsSOzzJT1JmWUAx0tZWG/BwKcFBHfceAPQl6pwxx28TM3BTBRYdzPJLTkAy48y6iXW6UYdfAPlShy79IYjQtEThTuIiEzdzgYdros0x3PDniuAP0KOKMgbikr0gRa6zahPjf0qqBnHeLB6nHAfaVzI0aNbhOg2bdOueE1FX0x48sjKqjOpjlIfq4WeZp9REr2YHEsoLFOBfgId5P3BPtpBQ== cardno:000612078454" + ]; + shell = pkgs.fish; + extraGroups = [ "wheel" "video" ]; + }; + }; + + options = { deploy.profile.kat = lib.mkEnableOption "uhh meow"; }; +} diff --git a/config/profiles/laptop/home.nix b/config/profiles/laptop/home.nix new file mode 100644 index 00000000..5bd3e36b --- /dev/null +++ b/config/profiles/laptop/home.nix @@ -0,0 +1,3 @@ +{ ... }: + +{ } diff --git a/config/profiles/laptop/nixos.nix b/config/profiles/laptop/nixos.nix new file mode 100644 index 00000000..6fc00512 --- /dev/null +++ b/config/profiles/laptop/nixos.nix @@ -0,0 +1,7 @@ +{ lib, ... }: + +{ + imports = [ ./nixos ]; + + options = { deploy.profile.laptop = lib.mkEnableOption "lappytop"; }; +} diff --git a/config/profiles/laptop/nixos/default.nix b/config/profiles/laptop/nixos/default.nix new file mode 100644 index 00000000..5bf7d32d --- /dev/null +++ b/config/profiles/laptop/nixos/default.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + imports = [ ./light.nix ./wifi.nix ]; +} diff --git a/config/profiles/laptop/nixos/light.nix b/config/profiles/laptop/nixos/light.nix new file mode 100644 index 00000000..7c084d93 --- /dev/null +++ b/config/profiles/laptop/nixos/light.nix @@ -0,0 +1,6 @@ +{ config, lib, pkgs, ... }: + +{ + config = + lib.mkIf config.deploy.profile.laptop { programs.light.enable = true; }; +} diff --git a/config/profiles/laptop/nixos/wifi.nix b/config/profiles/laptop/nixos/wifi.nix new file mode 100644 index 00000000..d1da9662 --- /dev/null +++ b/config/profiles/laptop/nixos/wifi.nix @@ -0,0 +1,5 @@ +{ config, lib, pkgs, ... }: + +{ + config = lib.mkIf config.deploy.profile.laptop { }; +} diff --git a/config/profiles/sway/home.nix b/config/profiles/sway/home.nix new file mode 100644 index 00000000..b931d1c8 --- /dev/null +++ b/config/profiles/sway/home.nix @@ -0,0 +1,7 @@ +{ lib, ... }: + +{ + imports = [ ./home ]; + + options = { deploy.profile.sway = lib.mkEnableOption "sway wm"; }; +} diff --git a/config/profiles/sway/home/default.nix b/config/profiles/sway/home/default.nix new file mode 100644 index 00000000..e2bf5fdf --- /dev/null +++ b/config/profiles/sway/home/default.nix @@ -0,0 +1,5 @@ +{ config, pkgs, sources, ... }: + +{ + imports = [ ./waybar ./mako.nix ./sway.nix ]; +} diff --git a/config/profiles/sway/home/mako.nix b/config/profiles/sway/home/mako.nix new file mode 100644 index 00000000..e7041670 --- /dev/null +++ b/config/profiles/sway/home/mako.nix @@ -0,0 +1,28 @@ +{ config, pkgs, lib, witch, ... }: + +{ + config = lib.mkIf config.deploy.profile.sway { + systemd.user.services = { + mako = { + Unit = { + Description = "mako"; + X-Restart-Triggers = + [ (toString config.xdg.configFile."mako/config".source) ]; + }; + Service = { + ExecStart = "${pkgs.mako}/bin/mako"; + Restart = "always"; + }; + Install = { WantedBy = [ "graphical-session.target" ]; }; + }; + }; + + programs.mako = { + enable = true; + defaultTimeout = 3000; + borderColor = witch.style.base16.color7; + backgroundColor = "${witch.style.base16.color0}70"; + textColor = witch.style.base16.color7; + }; + }; +} diff --git a/config/profiles/sway/home/sway.nix b/config/profiles/sway/home/sway.nix new file mode 100644 index 00000000..3ed8a8fc --- /dev/null +++ b/config/profiles/sway/home/sway.nix @@ -0,0 +1,210 @@ +{ config, pkgs, lib, witch, ... }: + +{ + config = lib.mkIf config.deploy.profile.sway { + home.sessionVariables = { + MOZ_ENABLE_WAYLAND = 1; + XDG_CURRENT_DESKTOP = "sway"; + XDG_SESSION_TYPE = "wayland"; + }; + + home.packages = with pkgs; [ grim slurp ]; + + wayland.windowManager.sway = { + enable = true; + config = let + dmenu = + "${pkgs.bemenu}/bin/bemenu --fn '${witch.style.font.name} ${witch.style.font.size}' --nb '${witch.style.base16.color0}' --nf '${witch.style.base16.color7}' --sb '${witch.style.base16.color1}' --sf '${witch.style.base16.color7}' -l 5 -m -1 -i"; + lockCommand = "swaylock -i ${./wallpapers/main.png} -s fill"; + cfg = config.wayland.windowManager.sway.config; + in { + bars = [{ command = "${pkgs.waybar}/bin/waybar"; }]; + + output = let + left = { + res = "1920x1080"; + pos = "0 0"; + bg = "${./wallpapers/left.jpg} fill"; + }; + middle = { + res = "1920x1080"; + pos = "1920 0"; + bg = "${./wallpapers/main.png} fill"; + }; + right = { + res = "1920x1080"; + pos = "3840 0"; + bg = "${./wallpapers/right.jpg} fill"; + }; + laptop = { + res = "1920x1080"; + pos = "0 0"; + bg = "${./wallpapers/main.png} fill"; + }; + in { + "DP-1" = left; + "DVI-D-1" = middle; + "HDMI-A-1" = right; + "eDP-1" = laptop; + }; + + input = { + "1739:33362:Synaptics_TM3336-002" = { + dwt = "enabled"; + tap = "enabled"; + natural_scroll = "enabled"; + middle_emulation = "enabled"; + click_method = "clickfinger"; + }; + "*" = { + xkb_layout = "gb"; + # xkb_variant = "nodeadkeys"; + # xkb_options = "ctrl:nocaps"; + }; + }; + + fonts = [ "${witch.style.font.name} ${witch.style.font.size}" ]; + terminal = "${pkgs.kitty}/bin/kitty"; + # TODO: replace with wofi + menu = + "${pkgs.j4-dmenu-desktop}/bin/j4-dmenu-desktop --dmenu=\"${dmenu}\" --term='${cfg.terminal}'"; + modifier = "Mod4"; + + startup = [ + { + command = "systemctl --user restart mako"; + always = true; + } + { + command = + "${pkgs.swayidle}/bin/swayidle -w before-sleep '${lockCommand}'"; + } + ]; + + window = { + border = 1; + titlebar = true; + }; + + keybindings = { + "${cfg.modifier}+Return" = "exec ${cfg.terminal}"; + + "${cfg.modifier}+Left" = "focus left"; + "${cfg.modifier}+Down" = "focus down"; + "${cfg.modifier}+Up" = "focus up"; + "${cfg.modifier}+Right" = "focus right"; + + "${cfg.modifier}+Shift+Left" = "move left"; + "${cfg.modifier}+Shift+Down" = "move down"; + "${cfg.modifier}+Shift+Up" = "move up"; + "${cfg.modifier}+Shift+Right" = "move right"; + + "${cfg.modifier}+Shift+space" = "floating toggle"; + "${cfg.modifier}+space" = "focus mode_toggle"; + + "${cfg.modifier}+1" = "workspace 1"; + "${cfg.modifier}+2" = "workspace 2"; + "${cfg.modifier}+3" = "workspace 3"; + "${cfg.modifier}+4" = "workspace 4"; + "${cfg.modifier}+5" = "workspace 5"; + "${cfg.modifier}+6" = "workspace 6"; + "${cfg.modifier}+7" = "workspace 7"; + "${cfg.modifier}+8" = "workspace 8"; + "${cfg.modifier}+9" = "workspace 9"; + "${cfg.modifier}+0" = "workspace 10"; + + "${cfg.modifier}+Shift+1" = "move container to workspace 1"; + "${cfg.modifier}+Shift+2" = "move container to workspace 2"; + "${cfg.modifier}+Shift+3" = "move container to workspace 3"; + "${cfg.modifier}+Shift+4" = "move container to workspace 4"; + "${cfg.modifier}+Shift+5" = "move container to workspace 5"; + "${cfg.modifier}+Shift+6" = "move container to workspace 6"; + "${cfg.modifier}+Shift+7" = "move container to workspace 7"; + "${cfg.modifier}+Shift+8" = "move container to workspace 8"; + "${cfg.modifier}+Shift+9" = "move container to workspace 9"; + "${cfg.modifier}+Shift+0" = "move container to workspace 10"; + + "XF86AudioRaiseVolume" = + "exec pactl set-sink-volume $(pacmd list-sinks |awk '/* index:/{print $3}') +5%"; + "XF86AudioLowerVolume" = + "exec pactl set-sink-volume $(pacmd list-sinks |awk '/* index:/{print $3}') -5%"; + "XF86AudioMute" = + "exec pactl set-sink-mute $(pacmd list-sinks |awk '/* index:/{print $3}') toggle"; + "XF86AudioMicMute" = + "exec pactl set-source-mute $(pacmd list-sources |awk '/* index:/{print $3}') toggle"; + "XF86MonBrightnessDown" = "exec ${pkgs.light}/bin/light -U 5"; + "XF86MonBrightnessUp" = "exec ${pkgs.light}/bin/light -A 5"; + + "${cfg.modifier}+d" = "exec ${cfg.menu}"; + "${cfg.modifier}+x" = "exec ${lockCommand}"; + + "${cfg.modifier}+i" = "move workspace to output left"; + "${cfg.modifier}+o" = "move workspace to output left"; + "${cfg.modifier}+b" = "splith"; + "${cfg.modifier}+v" = "splitv"; + "${cfg.modifier}+s" = "layout stacking"; + "${cfg.modifier}+w" = "layout tabbed"; + "${cfg.modifier}+e" = "layout toggle split"; + "${cfg.modifier}+f" = "fullscreen"; + + "${cfg.modifier}+Shift+q" = "kill"; + "${cfg.modifier}+Shift+c" = "reload"; + + "${cfg.modifier}+r" = "mode resize"; + "${cfg.modifier}+Delete" = '' + mode "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown"''; + }; + + modes = { + "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown" = + { + "l" = "exec ${lockCommand}, mode default"; + "e" = "exec swaymsg exit, mode default"; + "s" = "exec systemctl suspend, mode default"; + "h" = "exec systemctl hibernate, mode default"; + "r" = "exec systemctl reboot, mode default"; + "Shift+s" = "exec systemctl shutdown, mode default"; + "Return" = "mode default"; + "Escape" = "mode default"; + }; + }; + + colors = { + focused = { + border = witch.style.base16.color8; + background = witch.style.base16.color4; + text = witch.style.base16.color0; + indicator = witch.style.base16.color2; + childBorder = witch.style.base16.color8; + }; + focusedInactive = { + border = witch.style.base16.color0; + background = witch.style.base16.color11; + text = witch.style.base16.color12; + indicator = witch.style.base16.color2; + childBorder = witch.style.base16.color8; + }; + unfocused = { + border = witch.style.base16.color0; + background = witch.style.base16.color8; + text = witch.style.base16.color12; + indicator = witch.style.base16.color8; + childBorder = witch.style.base16.color8; + }; + urgent = { + border = witch.style.base16.color8; + background = witch.style.base16.color9; + text = witch.style.base16.color0; + indicator = witch.style.base16.color1; + childBorder = witch.style.base16.color8; + }; + }; + }; + wrapperFeatures.gtk = true; + extraConfig = '' + seat seat0 xcursor_theme breeze_cursors 20 + ''; + }; + }; + +} diff --git a/config/users/kat/wallpapers/left.jpg b/config/profiles/sway/home/wallpapers/left.jpg similarity index 100% rename from config/users/kat/wallpapers/left.jpg rename to config/profiles/sway/home/wallpapers/left.jpg diff --git a/config/users/kat/wallpapers/main.png b/config/profiles/sway/home/wallpapers/main.png similarity index 100% rename from config/users/kat/wallpapers/main.png rename to config/profiles/sway/home/wallpapers/main.png diff --git a/config/users/kat/wallpapers/right.jpg b/config/profiles/sway/home/wallpapers/right.jpg similarity index 100% rename from config/users/kat/wallpapers/right.jpg rename to config/profiles/sway/home/wallpapers/right.jpg diff --git a/config/profiles/sway/home/waybar/default.nix b/config/profiles/sway/home/waybar/default.nix new file mode 100644 index 00000000..d823eebd --- /dev/null +++ b/config/profiles/sway/home/waybar/default.nix @@ -0,0 +1,76 @@ +{ config, lib, pkgs, witch, ... }: + +{ + config = lib.mkIf config.deploy.profile.sway { + programs.waybar = { + enable = true; + style = import ./waybar.css.nix { + style = witch.style; + hextorgba = witch.colorhelpers.hextorgba; + }; + settings = [{ + modules-left = [ "sway/workspaces" "sway/mode" "sway/window" ]; + modules-center = [ "clock" "custom/weather" ]; + modules-right = [ + "pulseaudio" + "network" + "cpu" + "memory" + "temperature" + "backlight" + "battery" + "tray" + ]; + + modules = { + "custom/weather" = { + format = "{}"; + interval = 3600; + on-click = "xdg-open 'https://google.com/search?q=weather'"; + exec = "nix-shell --command 'python ${ + ../../../../../scripts/weather/weather.py + } ${witch.secrets.profiles.sway.city} ${witch.secrets.profiles.sway.api_key}' ${ + ../../../../../scripts/weather + }"; + }; + cpu = { format = " {usage}%"; }; + memory = { format = " {percentage}%"; }; + temperature = { format = "﨎 {temperatureC}°C"; }; + backlight = { + format = "{icon} {percent}%"; + format-icons = [ "" "" ]; + on-scroll-up = "${pkgs.light}/bin/light -A 1"; + on-scroll-down = "${pkgs.light}/bin/light -U 1"; + }; + battery = { + states = { + good = 90; + warning = 30; + critical = 15; + }; + format = "{icon} {capacity}%"; + format-charging = " {capacity}%"; + format-plugged = " {capacity}%"; + format-alt = "{icon} {time}"; + format-icons = [ "" "" "" "" "" ]; + }; + pulseaudio = { + format = " {volume}%"; + on-click = "pavucontrol"; + }; + network = { + format-wifi = " {essid} ({signalStrength}%)"; + format-ethernet = " {ifname}: {ipaddr}/{cidr}"; + format-linked = " {ifname} (No IP)"; + format-disconnected = " Disconnected "; + format-alt = " {ifname}: {ipaddr}/{cidr}"; + }; + clock = { + format = " {:%A, %F %T %Z}"; + interval = 1; + }; + }; + }]; + }; + }; +} diff --git a/config/users/kat/waybar/waybar.css.nix b/config/profiles/sway/home/waybar/waybar.css.nix similarity index 100% rename from config/users/kat/waybar/waybar.css.nix rename to config/profiles/sway/home/waybar/waybar.css.nix diff --git a/config/profiles/sway/nixos.nix b/config/profiles/sway/nixos.nix new file mode 100644 index 00000000..63d232c5 --- /dev/null +++ b/config/profiles/sway/nixos.nix @@ -0,0 +1,7 @@ +{ lib, ... }: + +{ + imports = [ ./nixos ]; + + options = { deploy.profile.sway = lib.mkEnableOption "sway wm"; }; +} diff --git a/config/profiles/sway/nixos/default.nix b/config/profiles/sway/nixos/default.nix new file mode 100644 index 00000000..50170fec --- /dev/null +++ b/config/profiles/sway/nixos/default.nix @@ -0,0 +1,5 @@ +{ config, pkgs, sources, ... }: + +{ + imports = [ ./sway.nix ]; +} diff --git a/config/profiles/sway/nixos/sway.nix b/config/profiles/sway/nixos/sway.nix new file mode 100644 index 00000000..622b82a5 --- /dev/null +++ b/config/profiles/sway/nixos/sway.nix @@ -0,0 +1,5 @@ +{ config, pkgs, lib, sources, ... }: + +{ + config = lib.mkIf config.deploy.profile.sway { programs.sway.enable = true; }; +} diff --git a/config/users/kat/default.nix b/config/users/kat/default.nix deleted file mode 100644 index 5bb8cb75..00000000 --- a/config/users/kat/default.nix +++ /dev/null @@ -1,100 +0,0 @@ -{ config, pkgs, sources, ... }: - -{ - imports = [ - ../../../modules/home - ./ssh.nix - ./desktop.nix - ./sound.nix - ./gaming.nix - ./network.nix - ./sway.nix - ./waybar - ./kitty.nix - ./emacs.nix - ]; - - users.users.kat = { - uid = 1000; - isNormalUser = true; - openssh.authorizedKeys.keys = [ - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCocjQqiDIvzq+Qu3jkf7FXw5piwtvZ1Mihw9cVjdVcsra3U2c9WYtYrA3rS50N3p00oUqQm9z1KUrvHzdE+03ZCrvaGdrtYVsaeoCuuvw7qxTQRbItTAEsfRcZLQ5c1v/57HNYNEsjVrt8VukMPRXWgl+lmzh37dd9w45cCY1QPi+JXQQ/4i9Vc3aWSe4X6PHOEMSBHxepnxm5VNHm4PObGcVbjBf0OkunMeztd1YYA9sEPyEK3b8IHxDl34e5t6NDLCIDz0N/UgzCxSxoz+YJ0feQuZtud/YLkuQcMxW2dSGvnJ0nYy7SA5DkW1oqcy6CGDndHl5StOlJ1IF9aGh0gGkx5SRrV7HOGvapR60RphKrR5zQbFFka99kvSQgOZqSB3CGDEQGHv8dXKXIFlzX78jjWDOBT67vA/M9BK9FS2iNnBF5x6shJ9SU5IK4ySxq8qvN7Us8emkN3pyO8yqgsSOzzJT1JmWUAx0tZWG/BwKcFBHfceAPQl6pwxx28TM3BTBRYdzPJLTkAy48y6iXW6UYdfAPlShy79IYjQtEThTuIiEzdzgYdros0x3PDniuAP0KOKMgbikr0gRa6zahPjf0qqBnHeLB6nHAfaVzI0aNbhOg2bdOueE1FX0x48sjKqjOpjlIfq4WeZp9REr2YHEsoLFOBfgId5P3BPtpBQ== cardno:000612078454" - ]; - shell = pkgs.fish; - extraGroups = [ "wheel" "video" ]; - packages = with pkgs; [ git-crypt gitAndTools.gitRemoteGcrypt ]; - }; - - home-manager.useGlobalPkgs = true; - home-manager.users.kat = { - programs.fish = { - enable = true; - shellAliases = { - nixdirfmt = "fd --color=never .nix | xargs nixfmt"; - tmne = "tmux new -s"; - tmat = "tmux attach -t"; - }; - plugins = [{ - name = "bass"; - src = pkgs.fetchFromGitHub { - owner = "edc"; - repo = "bass"; - rev = "d63054b24c2f63aaa3a08fb9ec9d0da4c70ab922"; - sha256 = "0pwci5xxm8308nrb52s5nyxijk0svar8nqrdfvkk2y34z1cg319b"; - }; - }]; - }; - - programs.starship = { - enable = true; - enableFishIntegration = true; - }; - - programs.git = { - enable = true; - package = pkgs.gitAndTools.gitFull; - userName = "kat witch"; - userEmail = "kat@kittywit.ch"; - extraConfig = { protocol.gcrypt.allow = "always"; }; - signing = { - key = "01F50A29D4AA91175A11BDB17248991EFA8EFBEE"; - signByDefault = true; - }; - }; - - programs.bat.enable = true; - programs.tmux = { - enable = true; - extraConfig = '' - - # modes - setw -g clock-mode-colour colour5 - setw -g mode-style 'fg=colour1 bg=colour18 bold' - - # panes - set -g pane-border-style 'fg=colour19 bg=colour0' - set -g pane-active-border-style 'bg=colour0 fg=colour9' - - # statusbar - set -g status-position bottom - set -g status-justify left - set -g status-style 'bg=colour18 fg=colour137 dim' - set -g status-left ''' - set -g status-right '#[fg=colour233,bg=colour19] %F #[fg=colour233,bg=colour8] %H:%M:%S %Z' - set -g status-right-length 50 - set -g status-left-length 20 - - setw -g window-status-current-style 'fg=colour1 bg=colour19 bold' - setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F ' - - setw -g window-status-style 'fg=colour9 bg=colour18' - setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F ' - - setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold' - - # messages - set -g message-style 'fg=colour232 bg=colour16 bold' - ''; - }; - }; -} diff --git a/config/users/kat/desktop.nix b/config/users/kat/desktop.nix deleted file mode 100644 index 11865965..00000000 --- a/config/users/kat/desktop.nix +++ /dev/null @@ -1,133 +0,0 @@ -{ config, lib, pkgs, ... }: - -let sources = import ../../../nix/sources.nix; -in { - imports = [ ./firefox ]; - - config = lib.mkIf (lib.elem "desktop" config.deploy.profiles) { - nixpkgs.config = { - mumble.speechdSupport = true; - pulseaudio = true; - }; - - services.xserver.enable = true; - services.xserver.displayManager.lightdm.enable = true; - programs.light.enable = true; - services.tumbler.enable = true; - - xdg = { - portal = { - enable = true; - extraPortals = with pkgs; [ - xdg-desktop-portal-wlr - xdg-desktop-portal-gtk - ]; - gtkUsePortal = true; - }; - }; - - users.users.kat = { - packages = with pkgs; [ - _1password - bitwarden - mpv - element-desktop - mumble - obs-studio - xfce.ristretto - audacity - avidemux - vlc - ffmpeg-full - thunderbird - unstable.syncplay - unstable.youtube-dl - unstable.google-chrome - v4l-utils - transmission-gtk - lm_sensors - baresip - psmisc - unstable.discord - tdesktop - yubikey-manager - pinentry.gtk2 - dino - nextcloud-client - vegur - nitrogen - terminator - pavucontrol - gparted - scrot - gimp-with-plugins - vscode - cryptsetup - pcmanfm - neofetch - htop - ]; - }; - - programs.gnupg.agent = { - enable = true; - enableSSHSupport = true; - pinentryFlavor = "gtk2"; - }; - - home-manager.users.kat = { - home.sessionVariables = { - MOZ_ENABLE_WAYLAND = 1; - XDG_CURRENT_DESKTOP = "sway"; - XDG_SESSION_TYPE = "wayland"; - }; - - home.file.".gnupg/gpg-agent.conf".text = '' - enable-ssh-support - pinentry-program ${pkgs.pinentry.gtk2}/bin/pinentry - ''; - - services.nextcloud-client.enable = true; - - services.kdeconnect = { - enable = true; - indicator = true; - }; - - gtk = { - enable = true; - iconTheme = { - name = "Numix-Square"; - package = pkgs.numix-icon-theme-square; - }; - theme = { - name = "Arc-Dark"; - package = pkgs.arc-theme; - }; - }; - }; - - services.pcscd.enable = true; - services.udev.packages = [ pkgs.yubikey-personalization ]; - - fonts.fontconfig.enable = true; - fonts.fonts = [ pkgs.nerdfonts pkgs.corefonts ]; - - # KDE Connect - networking.firewall = { - allowedTCPPortRanges = [{ - from = 1714; - to = 1764; - }]; - allowedUDPPortRanges = [{ - from = 1714; - to = 1764; - }]; - }; - - sound.enable = true; - hardware.pulseaudio.enable = true; - hardware.opengl.enable = true; - services.xserver.libinput.enable = true; - }; -} diff --git a/config/users/kat/gaming.nix b/config/users/kat/gaming.nix deleted file mode 100644 index af1298f8..00000000 --- a/config/users/kat/gaming.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - config = lib.mkIf (lib.elem "gaming" config.deploy.profiles) { - hardware.opengl.driSupport32Bit = true; - hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ libva ]; - hardware.pulseaudio.support32Bit = true; - - home-manager.users.kat = { - home.packages = [ pkgs.lutris pkgs.steam-run ]; - }; - }; -} diff --git a/config/users/kat/kitty.nix b/config/users/kat/kitty.nix deleted file mode 100644 index 3b9b31ef..00000000 --- a/config/users/kat/kitty.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ config, lib, pkgs, witch, ... }: - -{ - config = lib.mkIf (lib.elem "desktop" config.deploy.profiles) { - - home-manager.users.kat = { - programs.kitty = { - enable = true; - font.name = witch.style.font.name; - settings = { - font_size = witch.style.font.size; - background = witch.style.base16.color0; - background_opacity = "0.7"; - foreground = witch.style.base16.color7; - selection_background = witch.style.base16.color7; - selection_foreground = witch.style.base16.color0; - url_color = witch.style.base16.color3; - cursor = witch.style.base16.color7; - active_border_color = "#75715e"; - active_tab_background = "#9900ff"; - active_tab_foreground = witch.style.base16.color7; - inactive_tab_background = "#3a3a3a"; - inactive_tab_foreground = "#665577"; - } // witch.style.base16; - }; - }; - }; -} diff --git a/config/users/kat/sound.nix b/config/users/kat/sound.nix deleted file mode 100644 index dc26745a..00000000 --- a/config/users/kat/sound.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - config = lib.mkIf (lib.elem "desktop" config.deploy.profiles) { - sound.extraConfig = '' - defaults.pcm.rate_converter "speexrate_best" - ''; - hardware.pulseaudio.daemon.config = { - default-sample-format = "s24le"; - default-sample-rate = 96000; - resample-method = "soxr-vhq"; - }; - }; -} diff --git a/config/users/kat/sway.nix b/config/users/kat/sway.nix deleted file mode 100644 index 671c58d0..00000000 --- a/config/users/kat/sway.nix +++ /dev/null @@ -1,231 +0,0 @@ -{ config, pkgs, lib, witch, ... }: - -let - secrets = import ../../../secrets.nix; -in { - config = lib.mkIf (lib.elem "sway" config.deploy.profiles) { - - fonts.fonts = with pkgs; [ - font-awesome - nerdfonts - iosevka - emacs-all-the-icons-fonts - ]; - - programs.sway.enable = true; - users.users.kat.packages = with pkgs; [ grim slurp ]; - - systemd.user.services.mako = { - serviceConfig.ExecStart = "${pkgs.mako}/bin/mako"; - restartTriggers = - [ config.home-manager.users.kat.xdg.configFile."mako/config".source ]; - }; - - home-manager.users.kat = { - programs.mako = { - enable = true; - defaultTimeout = 3000; - borderColor = witch.style.base16.color7; - backgroundColor = "${witch.style.base16.color0}70"; - textColor = witch.style.base16.color7; - }; - - wayland.windowManager.sway = { - enable = true; - config = let - dmenu = - "${pkgs.bemenu}/bin/bemenu --fn '${witch.style.font.name} ${witch.style.font.size}' --nb '${witch.style.base16.color0}' --nf '${witch.style.base16.color7}' --sb '${witch.style.base16.color1}' --sf '${witch.style.base16.color7}' -l 5 -m -1 -i"; - lockCommand = "swaylock -i ${./wallpapers/main.png} -s fill"; - cfg = config.home-manager.users.kat.wayland.windowManager.sway.config; - in { - bars = [{ command = "${pkgs.waybar}/bin/waybar"; }]; - - output = let - left = { - res = "1920x1080"; - pos = "0 0"; - bg = "${./wallpapers/left.jpg} fill"; - }; - middle = { - res = "1920x1080"; - pos = "1920 0"; - bg = "${./wallpapers/main.png} fill"; - }; - right = { - res = "1920x1080"; - pos = "3840 0"; - bg = "${./wallpapers/right.jpg} fill"; - }; - laptop = { - res = "1920x1080"; - pos = "0 0"; - bg = "${./wallpapers/main.png} fill"; - }; - in { - "DP-1" = left; - "DVI-D-1" = middle; - "HDMI-A-1" = right; - "eDP-1" = laptop; - }; - - input = { - "1739:33362:Synaptics_TM3336-002" = { - dwt = "enabled"; - tap = "enabled"; - natural_scroll = "enabled"; - middle_emulation = "enabled"; - click_method = "clickfinger"; - }; - "*" = { - xkb_layout = "gb"; - # xkb_variant = "nodeadkeys"; - # xkb_options = "ctrl:nocaps"; - }; - }; - - fonts = [ "${witch.style.font.name} ${witch.style.font.size}" ]; - terminal = "${pkgs.kitty}/bin/kitty"; - # TODO: replace with wofi - menu = - "${pkgs.j4-dmenu-desktop}/bin/j4-dmenu-desktop --dmenu=\"${dmenu}\" --term='${cfg.terminal}'"; - modifier = "Mod4"; - - startup = [ - { - command = "systemctl --user restart mako"; - always = true; - } - { - command = - "${pkgs.swayidle}/bin/swayidle -w before-sleep '${lockCommand}'"; - } - ]; - - window = { - border = 1; - titlebar = true; - }; - - keybindings = { - "${cfg.modifier}+Return" = "exec ${cfg.terminal}"; - - "${cfg.modifier}+Left" = "focus left"; - "${cfg.modifier}+Down" = "focus down"; - "${cfg.modifier}+Up" = "focus up"; - "${cfg.modifier}+Right" = "focus right"; - - "${cfg.modifier}+Shift+Left" = "move left"; - "${cfg.modifier}+Shift+Down" = "move down"; - "${cfg.modifier}+Shift+Up" = "move up"; - "${cfg.modifier}+Shift+Right" = "move right"; - - "${cfg.modifier}+Shift+space" = "floating toggle"; - "${cfg.modifier}+space" = "focus mode_toggle"; - - "${cfg.modifier}+1" = "workspace 1"; - "${cfg.modifier}+2" = "workspace 2"; - "${cfg.modifier}+3" = "workspace 3"; - "${cfg.modifier}+4" = "workspace 4"; - "${cfg.modifier}+5" = "workspace 5"; - "${cfg.modifier}+6" = "workspace 6"; - "${cfg.modifier}+7" = "workspace 7"; - "${cfg.modifier}+8" = "workspace 8"; - "${cfg.modifier}+9" = "workspace 9"; - "${cfg.modifier}+0" = "workspace 10"; - - "${cfg.modifier}+Shift+1" = "move container to workspace 1"; - "${cfg.modifier}+Shift+2" = "move container to workspace 2"; - "${cfg.modifier}+Shift+3" = "move container to workspace 3"; - "${cfg.modifier}+Shift+4" = "move container to workspace 4"; - "${cfg.modifier}+Shift+5" = "move container to workspace 5"; - "${cfg.modifier}+Shift+6" = "move container to workspace 6"; - "${cfg.modifier}+Shift+7" = "move container to workspace 7"; - "${cfg.modifier}+Shift+8" = "move container to workspace 8"; - "${cfg.modifier}+Shift+9" = "move container to workspace 9"; - "${cfg.modifier}+Shift+0" = "move container to workspace 10"; - - "XF86AudioRaiseVolume" = - "exec pactl set-sink-volume $(pacmd list-sinks |awk '/* index:/{print $3}') +5%"; - "XF86AudioLowerVolume" = - "exec pactl set-sink-volume $(pacmd list-sinks |awk '/* index:/{print $3}') -5%"; - "XF86AudioMute" = - "exec pactl set-sink-mute $(pacmd list-sinks |awk '/* index:/{print $3}') toggle"; - "XF86AudioMicMute" = - "exec pactl set-source-mute $(pacmd list-sources |awk '/* index:/{print $3}') toggle"; - "XF86MonBrightnessDown" = "exec ${pkgs.light}/bin/light -U 5"; - "XF86MonBrightnessUp" = "exec ${pkgs.light}/bin/light -A 5"; - - "${cfg.modifier}+d" = "exec ${cfg.menu}"; - "${cfg.modifier}+x" = "exec ${lockCommand}"; - - "${cfg.modifier}+i" = "move workspace to output left"; - "${cfg.modifier}+o" = "move workspace to output left"; - "${cfg.modifier}+b" = "splith"; - "${cfg.modifier}+v" = "splitv"; - "${cfg.modifier}+s" = "layout stacking"; - "${cfg.modifier}+w" = "layout tabbed"; - "${cfg.modifier}+e" = "layout toggle split"; - "${cfg.modifier}+f" = "fullscreen"; - - "${cfg.modifier}+Shift+q" = "kill"; - "${cfg.modifier}+Shift+c" = "reload"; - - "${cfg.modifier}+r" = "mode resize"; - "${cfg.modifier}+Delete" = '' - mode "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown"''; - }; - - modes = { - "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown" = - { - "l" = "exec ${lockCommand}, mode default"; - "e" = "exec swaymsg exit, mode default"; - "s" = "exec systemctl suspend, mode default"; - "h" = "exec systemctl hibernate, mode default"; - "r" = "exec systemctl reboot, mode default"; - "Shift+s" = "exec systemctl shutdown, mode default"; - "Return" = "mode default"; - "Escape" = "mode default"; - }; - }; - - colors = { - focused = { - border = witch.style.base16.color8; - background = witch.style.base16.color4; - text = witch.style.base16.color0; - indicator = witch.style.base16.color2; - childBorder = witch.style.base16.color8; - }; - focusedInactive = { - border = witch.style.base16.color0; - background = witch.style.base16.color11; - text = witch.style.base16.color12; - indicator = witch.style.base16.color2; - childBorder = witch.style.base16.color8; - }; - unfocused = { - border = witch.style.base16.color0; - background = witch.style.base16.color8; - text = witch.style.base16.color12; - indicator = witch.style.base16.color8; - childBorder = witch.style.base16.color8; - }; - urgent = { - border = witch.style.base16.color8; - background = witch.style.base16.color9; - text = witch.style.base16.color0; - indicator = witch.style.base16.color1; - childBorder = witch.style.base16.color8; - }; - }; - }; - wrapperFeatures.gtk = true; - extraConfig = '' - seat seat0 xcursor_theme breeze_cursors 20 - ''; - }; - - }; - }; -} diff --git a/config/users/kat/waybar/default.nix b/config/users/kat/waybar/default.nix deleted file mode 100644 index bc902851..00000000 --- a/config/users/kat/waybar/default.nix +++ /dev/null @@ -1,80 +0,0 @@ -{ config, lib, pkgs, witch, ... }: - -let - secrets = import ../../../../secrets.nix; -in { - config = lib.mkIf (lib.elem "sway" config.deploy.profiles) { - home-manager.users.kat = { - programs.waybar = { - enable = true; - style = import ./waybar.css.nix { - style = witch.style; - hextorgba = witch.colorhelpers.hextorgba; - }; - settings = [{ - modules-left = [ "sway/workspaces" "sway/mode" "sway/window" ]; - modules-center = [ "clock" "custom/weather" ]; - modules-right = [ - "pulseaudio" - "network" - "cpu" - "memory" - "temperature" - "backlight" - "battery" - "tray" - ]; - - modules = { - "custom/weather" = { - format = "{}"; - interval = 3600; - on-click = "xdg-open 'https://google.com/search?q=weather'"; - exec = "nix-shell --command 'python ${ - ../../../../scripts/weather/weather.py - } ${secrets.profiles.sway.city} ${secrets.profiles.sway.api_key}' ${ - ../../../../scripts/weather - }"; - }; - cpu = { format = " {usage}%"; }; - memory = { format = " {percentage}%"; }; - temperature = { format = "﨎 {temperatureC}°C"; }; - backlight = { - format = "{icon} {percent}%"; - format-icons = [ "" "" ]; - on-scroll-up = "${pkgs.light}/bin/light -A 1"; - on-scroll-down = "${pkgs.light}/bin/light -U 1"; - }; - battery = { - states = { - good = 90; - warning = 30; - critical = 15; - }; - format = "{icon} {capacity}%"; - format-charging = " {capacity}%"; - format-plugged = " {capacity}%"; - format-alt = "{icon} {time}"; - format-icons = [ "" "" "" "" "" ]; - }; - pulseaudio = { - format = " {volume}%"; - on-click = "pavucontrol"; - }; - network = { - format-wifi = " {essid} ({signalStrength}%)"; - format-ethernet = " {ifname}: {ipaddr}/{cidr}"; - format-linked = " {ifname} (No IP)"; - format-disconnected = " Disconnected "; - format-alt = " {ifname}: {ipaddr}/{cidr}"; - }; - clock = { - format = " {:%A, %F %T %Z}"; - interval = 1; - }; - }; - }]; - }; - }; - }; -} diff --git a/default.nix b/default.nix index 8a46f79d..a4468451 100644 --- a/default.nix +++ b/default.nix @@ -6,9 +6,9 @@ rec { hosts = import ./lib/hosts.nix { inherit pkgs sources witch; }; inherit (pkgs) lib; - + deploy = import ./lib/deploy.nix { inherit pkgs; - inherit (hosts) hosts profiles; + inherit (hosts) hosts groups; }; } diff --git a/lib/deploy.nix b/lib/deploy.nix index 18f7bda0..fd3a0312 100644 --- a/lib/deploy.nix +++ b/lib/deploy.nix @@ -1,9 +1,9 @@ -{ pkgs, hosts, profiles }: +{ pkgs, hosts, groups }: with pkgs.lib; (mapAttrs (name: hosts: - pkgs.writeScript "deploy-profile-${name}" '' + pkgs.writeScript "deploy-group-${name}" '' #!${pkgs.runtimeShell} export PATH= ${concatMapStrings (host: '' @@ -14,5 +14,5 @@ with pkgs.lib; # FIXME: remove jobs from PIDLIST once they finish trap "kill $PID_LIST" SIGINT wait $PID_LIST - '') profiles) + '') groups) // (mapAttrs (name: host: host.config.system.build.deployScript) hosts) diff --git a/lib/hosts.nix b/lib/hosts.nix index cdd8cd78..f5546d3d 100644 --- a/lib/hosts.nix +++ b/lib/hosts.nix @@ -1,12 +1,6 @@ -{ - pkgs, - hostsDir ? ../config/hosts, - privateHostsDir ? ../config/private/hosts, - commonImports ? [ ../config/common ../modules/nixos ], - pkgsPath ? ../pkgs, - sources ? {}, - witch ? {} -}: +{ pkgs, hostsDir ? ../config/hosts, privateHostsDir ? ../config/private/hosts +, commonImports ? [ ../config/nixos.nix ../modules/nixos ], pkgsPath ? ../pkgs +, sources ? { }, witch ? { } }: with pkgs.lib; @@ -14,41 +8,38 @@ rec { hostNames = attrNames (filterAttrs (name: type: type == "directory") (builtins.readDir hostsDir)); - hostConfig = hostName: { config, ... }: { - _module.args = { - inherit hosts profiles; + hostConfig = hostName: + { config, ... }: { + _module.args = { inherit hosts groups; }; + imports = [ + (import (hostsDir + "/${hostName}/configuration.nix")) + (import (privateHostsDir + "/${hostName}/configuration.nix")) + ../modules/nixos/deploy + ] ++ commonImports; + networking = { inherit hostName; }; + nixpkgs.pkgs = import pkgsPath { + inherit (config.nixpkgs) config; + inherit sources; + }; }; - imports = [ - (import (hostsDir + "/${hostName}/configuration.nix")) - (import (privateHostsDir + "/${hostName}/configuration.nix")) - ../modules/nixos/deploy - ] ++ commonImports; - networking = { - inherit hostName; - }; - nixpkgs.pkgs = import pkgsPath { inherit (config.nixpkgs) config; inherit sources; }; - }; + hosts = listToAttrs (map (hostName: + nameValuePair hostName (import (pkgs.path + "/nixos/lib/eval-config.nix") { + modules = [ + (hostConfig hostName) + (if sources ? home-manager then + sources.home-manager + "/nixos" + else + { }) + ]; + specialArgs = { inherit sources witch; }; + })) hostNames); - hosts = listToAttrs ( - map ( - hostName: nameValuePair hostName ( - import (pkgs.path + "/nixos/lib/eval-config.nix") { - modules = [ - (hostConfig hostName) - (if sources ? home-manager then sources.home-manager + "/nixos" else {}) - ]; - specialArgs = { inherit sources witch; }; - } - ) - ) hostNames - ); + groupNames = unique (concatLists + (mapAttrsToList (name: host: host.config.deploy.groups) hosts)); - profileNames = unique (concatLists - (mapAttrsToList (name: host: host.config.deploy.profiles) hosts)); - - profiles = listToAttrs (map (profileName: - nameValuePair profileName - (filter (host: elem profileName host.config.deploy.profiles) - (attrValues hosts))) profileNames); + groups = listToAttrs (map (groupName: + nameValuePair groupName + (filter (host: elem groupName host.config.deploy.groups) + (attrValues hosts))) groupNames); } diff --git a/lib/modules.nix b/lib/modules.nix index ae52bdcb..6f37ffb7 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -1,22 +1,23 @@ -{ - modulesDir, - defaultFile ? "default.nix", - importAll ? false -}: +{ modulesDir, defaultFile ? "default.nix", importAll ? false }: with builtins; let - filterAttrNamesToList = filter: set: foldl' (a: b: a ++ b) [] ( - map (e: if (filter e set.${e}) then [ e ] else []) (attrNames set) - ); + filterAttrNamesToList = filter: set: + foldl' (a: b: a ++ b) [ ] + (map (e: if (filter e set.${e}) then [ e ] else [ ]) (attrNames set)); nameValuePair = name: value: { inherit name value; }; - listToAttrs = foldl' (acc: val: acc // { ${val.name} = val.value; }) {}; - directories = filterAttrNamesToList (_: type: type == "directory") (readDir modulesDir); - files = map (dir: nameValuePair dir (modulesDir + "/${dir}/${defaultFile}")) directories; - modules = map ({name, value}: + listToAttrs = foldl' (acc: val: acc // { ${val.name} = val.value; }) { }; + directories = + filterAttrNamesToList (_: type: type == "directory") (readDir modulesDir); + files = map (dir: nameValuePair dir (modulesDir + "/${dir}/${defaultFile}")) + directories; + modules = map ({ name, value }: # if the file contains a function, assume it to be a module and pass the path # (for dedup and such). if it contains anything else, pass that. - let m = import value; in { inherit name; value = if (isFunction m) && !importAll then value else m; } - ) files; + let m = import value; + in { + inherit name; + value = if (isFunction m) && !importAll then value else m; + }) files; in (listToAttrs modules) diff --git a/lib/witch.nix b/lib/witch.nix index 0a31c88d..6ee656a2 100644 --- a/lib/witch.nix +++ b/lib/witch.nix @@ -1,6 +1,8 @@ -{ lib }: +{ lib }: { - style = import ./style.nix; - colorhelpers = import ./colorhelpers.nix { inherit lib; }; -} \ No newline at end of file + style = import ./style.nix; + colorhelpers = import ./colorhelpers.nix { inherit lib; }; + secrets = import ./secrets.nix; + modList = import ./modules.nix; +} diff --git a/modules/home/default.nix b/modules/home/default.nix index 1c743da3..41356c0c 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -1,9 +1,5 @@ { sources, ... }: { - home-manager.users.kat = { - imports = [ - (sources.tf-nix + "/modules/home/secrets.nix") - ]; - }; -} \ No newline at end of file + imports = [ (sources.tf-nix + "/modules/home/secrets.nix") ]; +} diff --git a/modules/nixos/deploy/default.nix b/modules/nixos/deploy/default.nix index 51d587b6..e3c628d7 100644 --- a/modules/nixos/deploy/default.nix +++ b/modules/nixos/deploy/default.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: +{ config, pkgs, lib, options, ... }: with lib; @@ -35,11 +35,18 @@ in { type = with types; listOf str; default = [ ]; }; + groups = mkOption { + type = with types; listOf str; + default = [ ]; + }; }; }; config = mkIf cfg.enable { - deploy.profiles = [ "all" ]; + deploy.profile = mkMerge (map (prof: { + ${if options ? deploy.profile.${prof} then prof else null} = true; + }) config.deploy.profiles); + deploy.groups = [ "all" ]; system.build.deployScript = pkgs.writeScript "deploy-${config.networking.hostName}" '' diff --git a/pkgs/screenstub/default.nix b/pkgs/screenstub/default.nix index aee0d172..42fb6dc0 100644 --- a/pkgs/screenstub/default.nix +++ b/pkgs/screenstub/default.nix @@ -1,4 +1,5 @@ { fetchFromGitHub, rustPlatform, pkg-config, lib, libxcb, udev, python3 }: + rustPlatform.buildRustPackage rec { pname = "screenstub"; version = "2021-01-08"; diff --git a/todo.org b/todo.org index 34c77b1e..61f2deca 100644 --- a/todo.org +++ b/todo.org @@ -3,9 +3,12 @@ ** TODO Add dork.dev to mailserver ** TODO Migrate non-PGSQL services to PGSQL ** TODO Gitea theme + resources overwrite - See PBB gitea -** Replace current display manager. -** Move network config away from network manager. -** Change profile structure. +** TODO Move network config away from network manager. +** TODO Separate home-manager closure +** TODO Nixfiles working outside of NixOS, e.g. Fedora + macOS +** TODO Investigate nix-darwin +** TODO Investigate pipewire +** TODO Investigate audio source switching (Arctis 5, integrated front, integrated back) * Secrets handling