diff --git a/TODO.md b/TODO.md index 347253e..4dd3a60 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,5 @@ * [ ] Simplify config -* [ ] Organize most common apps with modules +* [x] Organize most common apps with modules * [ ] Migrate from pywal + apple-fonts to Stylix (theme, cursor, fonts, ...) -* [ ] Remove clutter +* [x] Remove clutter +* [ ] Fix DDT4ALL derivation/shell diff --git a/derivations/ddt4all.nix b/derivations/ddt4all.nix deleted file mode 100644 index 9f1c64b..0000000 --- a/derivations/ddt4all.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ pkgs, stdenv, fetchFromGitHub }: - -let - python = pkgs.python3.withPackages (pkgs: with pkgs; [ pyqt5 pyqtwebengine pyusb crcmod pyserial ]); -in stdenv.mkDerivation rec { - pname = "ddt4all"; - version = "1.0.0"; - - src = fetchFromGitHub { - owner = "cedricp"; - repo = "ddt4all"; - rev = "master"; - sha256 = "sha256-1D1fnnFWxBV6sZkfbBc7a/7DSZvZtXeEYM9fRsQ7Ag0="; - }; - - nativeBuildInputs = [ - python - pkgs.libsForQt5.qt5.wrapQtAppsHook - pkgs.libsForQt5.qt5.qttools - pkgs.which - ]; - - propagatedBuildInputs = [ - python - pkgs.libsForQt5.qt5.qtbase - pkgs.libsForQt5.qt5.qttools - ]; - - configurePhase = '' - runHook preConfigure - wrapQtAppsHook - runHook postConfigure - ''; - - buildPhase = ""; - - installPhase = '' - mkdir -p $out/bin - cp -r * $out/ - ln -s $out/main.py $out/bin/ddt4all - ''; -} diff --git a/flake.nix b/flake.nix index 2adcb0d..214b5df 100644 --- a/flake.nix +++ b/flake.nix @@ -16,7 +16,20 @@ fingerprint-sensor.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { self, ... }: { + outputs = { self, nixpkgs, ... }: let + forAllSystems = nixpkgs.lib.genAttrs [ + "aarch64-linux" + "x86_64-linux" + "aarch64-darwin" + ]; + in { nixosConfigurations = import ./hosts { inherit self; }; + devShells = forAllSystems ( system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in { + ddt4all = import ./shells/ddt4all.nix { inherit pkgs; }; + } + ); }; } diff --git a/hosts/default.nix b/hosts/default.nix index 176cfef..7e33026 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -2,21 +2,29 @@ let inherit (self) inputs; - system = "x86_64-linux"; homeDir = self + /profiles; - pkgs = inputs.nixpkgs.legacyPackages.${system}; - mkSystem = pkgs: hostname: - pkgs.lib.nixosSystem { - specialArgs = { - inherit inputs; - }; - modules = [ - ./base-configuration.nix - ./${hostname} - homeDir - inputs.home-manager.nixosModules.home-manager - ]; - }; + + mkSystem = { + system, + hostname, + useHomeManager ? true, + modules ? [] + }: inputs.nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + ./base-configuration.nix + ./${hostname} + homeDir + ] ++ ( + if useHomeManager then + [ inputs.home-manager.nixosModules.home-manager ] + else + [ ] + ) ++ modules; + }; in { - hulk = mkSystem inputs.nixpkgs "hulk"; + hulk = mkSystem { + system = "x86_64-linux"; + hostname = "hulk"; + }; } diff --git a/modules/home-manager/fish.nix b/modules/home-manager/fish.nix new file mode 100644 index 0000000..cc46288 --- /dev/null +++ b/modules/home-manager/fish.nix @@ -0,0 +1,77 @@ +{ config, lib, ... }: + +{ + options.modules.fish = { + enable = lib.mkEnableOption "Fish integration"; + enableDefaultAliases = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enable default aliases and abbreviations"; + }; + + enableStarship = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable Starship prompt"; + }; + + functions = lib.mkOption { + type = with lib.types; attrsOf str; + description = "Fish function definitions"; + }; + }; + + config = lib.mkIf config.modules.fish.enable { + programs.nix-index = { + enable = true; + enableFishIntegration = true; + }; + + programs.starship = lib.mkIf config.modules.fish.enableStarship { + enable = true; + enableFishIntegration = true; + }; + + programs.fish = { + enable = true; + interactiveShellInit = '' + set fish_greeting + cat ~/.cache/wal/sequences + ''; + + shellAliases = lib.mkIf config.modules.fish.enableDefaultAliases { + ".." = "cd .."; + "..." = "cd ../.."; + "...." = "cd ../../../"; + "....." = "cd ../../../../"; + + "cp" = "cp -v"; + "ddf" = "df -h"; + "etc" = "erd -H"; + "mkdir" = "mkdir -p"; + "mv" = "mv -v"; + "rm" = "rm -v"; + "rr" = "rm -rf"; + + "neofetch" = "fastfetch"; + }; + + shellAbbrs = lib.mkIf config.modules.fish.enableDefaultAliases { + gaa = "git add -A"; + ga = "git add"; + gbd = "git branch --delete"; + gb = "git branch"; + gc = "git commit"; + gcm = "git commit -m"; + gcob = "git checkout -b"; + gco = "git checkout"; + gd = "git diff"; + gl = "git log"; + gp = "git push"; + gs = "git status"; + }; + + functions = config.modules.fish.functions; + }; + }; +} diff --git a/profiles/default.nix b/profiles/default.nix index 0e68031..476f5bd 100644 --- a/profiles/default.nix +++ b/profiles/default.nix @@ -1,6 +1,5 @@ { self, impurity, inputs, ... }: { home-manager = { - verbose = true; useGlobalPkgs = true; useUserPackages = true; backupFileExtension = "bak"; diff --git a/profiles/hulk/fish-functions.nix b/profiles/hulk/fish-functions.nix new file mode 100644 index 0000000..3f51900 --- /dev/null +++ b/profiles/hulk/fish-functions.nix @@ -0,0 +1,32 @@ +{ + webcopy = '' + set -l domain (string trim $argv) + get --recursive \ + --level 5 \ + --no-clobber \ + --page-requisites \ + --adjust-extension \ + --span-hosts \ + --convert-links \ + --domains $domain \ + --no-parent \ + $domain + ''; + + venv = '' + if [ -d .venv ]; then + source .venv/bin/activate.fish + else + python -m venv .venv + source .venv/bin/activate.fish + fi + ''; + + thunderbird = '' + if pgrep -x birdtray > /dev/null + birdtray -s + else + birdtray & + end + ''; +} diff --git a/profiles/hulk/fish/default.nix b/profiles/hulk/fish/default.nix deleted file mode 100644 index 7154f7d..0000000 --- a/profiles/hulk/fish/default.nix +++ /dev/null @@ -1,77 +0,0 @@ -{ - imports = [ - ./starship.nix - ./nix-index.nix - ]; - - programs.fish = { - enable = true; - interactiveShellInit = '' - set fish_greeting - cat ~/.cache/wal/sequences - ''; - shellAliases = { - ".." = "cd .."; - "..." = "cd ../.."; - "...." = "cd ../../../"; - "....." = "cd ../../../../"; - - "cp" = "cp -v"; - "ddf" = "df -h"; - "etc" = "erd -H"; - "mkdir" = "mkdir -p"; - "mv" = "mv -v"; - "rm" = "rm -v"; - "rr" = "rm -rf"; - - "neofetch" = "fastfetch"; - }; - - shellAbbrs = { - gaa = "git add -A"; - ga = "git add"; - gbd = "git branch --delete"; - gb = "git branch"; - gc = "git commit"; - gcm = "git commit -m"; - gcob = "git checkout -b"; - gco = "git checkout"; - gd = "git diff"; - gl = "git log"; - gp = "git push"; - gs = "git status"; - }; - - functions = { - webcopy = '' - function webcopy - set -l domain (string trim $argv) - wget --recursive \ - --level 5 \ - --no-clobber \ - --page-requisites \ - --adjust-extension \ - --span-hosts \ - --convert-links \ - --domains $domain \ - --no-parent \ - $domain - end - ''; - - venv = '' - function venv - source .venv/bin/activate.fish - end - ''; - - thunderbird = '' - if pgrep -x birdtray > /dev/null - birdtray -s - else - birdtray & - end - ''; - }; - }; -} diff --git a/profiles/hulk/fish/nix-index.nix b/profiles/hulk/fish/nix-index.nix deleted file mode 100644 index 0381d27..0000000 --- a/profiles/hulk/fish/nix-index.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - programs.nix-index = { - enable = true; - enableFishIntegration = true; - }; -} diff --git a/profiles/hulk/fish/starship.nix b/profiles/hulk/fish/starship.nix deleted file mode 100644 index b00e6d1..0000000 --- a/profiles/hulk/fish/starship.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - programs.starship = { - enable = true; - enableFishIntegration = true; - }; -} diff --git a/profiles/hulk/packages.nix b/profiles/hulk/packages.nix index e0c3f24..12e1013 100644 --- a/profiles/hulk/packages.nix +++ b/profiles/hulk/packages.nix @@ -1,17 +1,6 @@ { pkgs, inputs, ... }: { - imports = [ - ../../modules/home-manager/darkman.nix - inputs.ags.homeManagerModules.default - ]; - - modules.darkman = { - enable = true; - customLightModeScript = "$HOME/.config/hypr/scripts/random-wallpaper.sh"; - customDarkModeScript = "$HOME/.config/hypr/scripts/random-wallpaper.sh"; - }; - home.packages = with pkgs; [ pywal pywalfox-native @@ -20,7 +9,6 @@ ])) inputs.nordvpn.packages.${system}.nordvpn - (pkgs.callPackage ../../derivations/ddt4all.nix {}) (birdtray.overrideAttrs (_: { cmakeFlags = [ "-DOPT_THUNDERBIRD_CMDLINE=${thunderbird}/bin/thunderbird" ]; diff --git a/profiles/hulk/programs.nix b/profiles/hulk/programs.nix index 1d5816c..73dd390 100644 --- a/profiles/hulk/programs.nix +++ b/profiles/hulk/programs.nix @@ -1,8 +1,24 @@ { inputs, pkgs, ... }: { - imports = [ ./fish ]; + imports = [ + ../../modules/home-manager/darkman.nix + ../../modules/home-manager/fish.nix + inputs.ags.homeManagerModules.default + ]; + + modules.darkman = { + enable = true; + customLightModeScript = "$HOME/.config/hypr/scripts/random-wallpaper.sh"; + customDarkModeScript = "$HOME/.config/hypr/scripts/random-wallpaper.sh"; + }; + modules.fish = { + enable = true; + enableStarship = true; + functions = import ./fish-functions.nix; + }; + programs.pywal.enable = true; programs.ags = { enable = true; @@ -21,40 +37,8 @@ #advanced-scene-switcher obs-tuna obs-move-transition - droidcam-obs waveform wlrobs ]; }; - - services.darkman = { - enable = true; - darkModeScripts = { - theme = '' - ${pkgs.dconf}/bin/dconf write\ - /org/gnome/desktop/interface/color-scheme "'prefer-dark'" - ''; - - wallpaper = '' - $HOME/.config/hypr/scripts/random-wallpaper.sh - ''; - - pywalfox = "command -v pywalfox &>/dev/null && pywalfox dark && pywalfox update"; - }; - - lightModeScripts = { - theme = '' - ${pkgs.dconf}/bin/dconf write\ - /org/gnome/desktop/interface/color-scheme "'prefer-light'" - ''; - - wallpaper = '' - $HOME/.config/hypr/scripts/random-wallpaper.sh - ''; - - pywalfox = "command -v pywalfox &>/dev/null && pywalfox light && pywalfox update"; - }; - - settings.usegeoclue = true; - }; } diff --git a/shell.nix b/shell.nix deleted file mode 100644 index add5aad..0000000 --- a/shell.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ pkgs ? import {} }: - -let - pythonWithPkgs = pkgs.python3.withPackages (ps: with ps; [ - ps.pyqt5 - ps.pyqtwebengine - ps.pyusb - ps.crcmod - ps.pyserial - ]); -in - -pkgs.mkShell { - name = "ddt4all-env"; - - buildInputs = [ - pythonWithPkgs - pkgs.qt5.qtbase - pkgs.qt5.qttools - pkgs.git - pkgs.freetype - pkgs.libGL - pkgs.dbus - pkgs.xorg.libX11 - pkgs.xorg.libXcomposite - pkgs.xorg.libXdamage - pkgs.xorg.libXfixes - pkgs.xorg.libXrender - pkgs.xorg.libXrandr - pkgs.xorg.libXtst - pkgs.glib - pkgs.expat - pkgs.fontconfig - ]; - - nativeBuildInputs = [ pkgs.libsForQt5.qt5.wrapQtAppsHook ]; - shellHook = ''wrapQtAppsHook''; - - runScript = '' - cd $HOME/DDT4ALL - - if [ ! -d ".venv" ]; then - python3 -m venv .venv - source .venv/bin/activate - pip install --upgrade pip - pip install -r requirements.txt - else - source .venv/bin/activate - fi - - python3 main.py - ''; -} diff --git a/shells/ddt4all.nix b/shells/ddt4all.nix new file mode 100644 index 0000000..e29bfbe --- /dev/null +++ b/shells/ddt4all.nix @@ -0,0 +1,51 @@ +{ pkgs, ... }: + +let + pythonWithPkgs = pkgs.python3.withPackages (ps: with ps; [ + ps.pyqt5 + ps.pyqtwebengine + ps.pyusb + ps.crcmod + ps.pyserial + ]); +in pkgs.mkShell { + name = "ddt4all-env"; + + buildInputs = [ + pythonWithPkgs + pkgs.qt5.qtbase + pkgs.qt5.qttools + pkgs.git + pkgs.freetype + pkgs.libGL + pkgs.dbus + pkgs.xorg.libX11 + pkgs.xorg.libXcomposite + pkgs.xorg.libXdamage + pkgs.xorg.libXfixes + pkgs.xorg.libXrender + pkgs.xorg.libXrandr + pkgs.xorg.libXtst + pkgs.glib + pkgs.expat + pkgs.fontconfig + ]; + + nativeBuildInputs = [ pkgs.libsForQt5.qt5.wrapQtAppsHook ]; + shellHook = ''wrapQtAppsHook''; + + runScript = '' + cd $HOME/DDT4ALL + + if [ ! -d ".venv" ]; then + python3 -m venv .venv + source .venv/bin/activate + pip install --upgrade pip + pip install -r requirements.txt + else + source .venv/bin/activate + fi + + python3 main.py + ''; +}