From 3d0fd7a030886c9ec64e66d7d733efb3c76a2e57 Mon Sep 17 00:00:00 2001 From: yukkop Date: Thu, 17 Jul 2025 15:48:20 +0000 Subject: [PATCH] refactor: pull out flake devshells --- devshell/c.nix | 17 ++++++++++ devshell/default.nix | 24 ++++++++++++++ devshell/haskell.nix | 8 +++++ devshell/postgres-c.nix | 22 +++++++++++++ devshell/pure-c.nix | 14 ++++++++ devshell/rust.nix | 17 ++++++++++ flake.nix | 71 ++++------------------------------------- 7 files changed, 109 insertions(+), 64 deletions(-) create mode 100644 devshell/c.nix create mode 100644 devshell/default.nix create mode 100644 devshell/haskell.nix create mode 100644 devshell/postgres-c.nix create mode 100644 devshell/pure-c.nix create mode 100644 devshell/rust.nix diff --git a/devshell/c.nix b/devshell/c.nix new file mode 100644 index 0000000..d39f163 --- /dev/null +++ b/devshell/c.nix @@ -0,0 +1,17 @@ +{ + system, + pkgs, + self +}: pkgs.mkShell { + buildInputs = (with pkgs; [ + inotify-tools + gdb + gcc + ]) ++ (with self.packages.${system}; [ + c-hectic + nvim-pager + watch + ]); + + PAGER = "${self.packages.${system}.nvim-pager}/bin/pager"; + } diff --git a/devshell/default.nix b/devshell/default.nix new file mode 100644 index 0000000..46cb4f8 --- /dev/null +++ b/devshell/default.nix @@ -0,0 +1,24 @@ +{ + system, + pkgs, + self +}: pkgs.mkShell { + buildInputs = + (with self.packages.${system}; [ + nvim-alias + #prettify-log + nvim-pager + ]) + ++ (with pkgs; [ + git + jq + yq-go + curl + (writeScriptBin "hemar-check" '' + ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null vm-postgres 'zsh -c check' + '') + ]); + + # environment + PAGER = "${self.packages.${system}.nvim-pager}/bin/pager"; +} diff --git a/devshell/haskell.nix b/devshell/haskell.nix new file mode 100644 index 0000000..f93fd5f --- /dev/null +++ b/devshell/haskell.nix @@ -0,0 +1,8 @@ +{ + system, + pkgs, + self +}: self.devShells.${system}.default + // (pkgs.mkShell { + buildInputs = [pkgs.stack]; + }) diff --git a/devshell/postgres-c.nix b/devshell/postgres-c.nix new file mode 100644 index 0000000..0317852 --- /dev/null +++ b/devshell/postgres-c.nix @@ -0,0 +1,22 @@ +{ + system, + pkgs, + self +}: pkgs.mkShell { + buildInputs = (with pkgs; [ + inotify-tools + postgresql_15 + ]) ++ (with self.packages.${system}; [ + nvim-pager + ]) ++ (with pkgs; [ + gdb + gcc + ]); + + PAGER = "${self.packages.${system}.nvim-pager}/bin/pager"; + + shellHook = '' + export PATH=${pkgs.gcc}/bin:$PATH + export PAGER="${self.packages.${system}.nvim-pager}/bin/pager" + ''; +} diff --git a/devshell/pure-c.nix b/devshell/pure-c.nix new file mode 100644 index 0000000..e453b0c --- /dev/null +++ b/devshell/pure-c.nix @@ -0,0 +1,14 @@ +{ + system, + pkgs, + self +}: pkgs.mkShell { + buildInputs = (with pkgs; [ inotify-tools ]) ++ (with self.packages.${system}; [ nvim-pager ]) ++ (with pkgs; [ gdb gcc binutils ]); + PAGER = "${self.packages.${system}.nvim-pager}/bin/pager"; + + shellHook = '' + export PATH=${pkgs.gcc}/bin:$PATH + + export PAGER="${self.packages.${system}.nvim-pager}/bin/pager" + ''; +} diff --git a/devshell/rust.nix b/devshell/rust.nix new file mode 100644 index 0000000..b5f4940 --- /dev/null +++ b/devshell/rust.nix @@ -0,0 +1,17 @@ +{ + self, + pkgs, + system +}: let + rustToolchain = + if builtins.pathExists ./rust-toolchain.toml + then pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml + else pkgs.pkgsBuildHost.rust-bin.stable."1.81.0".default; +in + self.devShells.${system}.default + // (pkgs.mkShell { + nativeBuildInputs = [ + rustToolchain + pkgs.pkg-config + ]; + }) diff --git a/flake.nix b/flake.nix index 4c25c89..d322f69 100644 --- a/flake.nix +++ b/flake.nix @@ -27,70 +27,13 @@ }: { packages.${system} = import ./package { inherit system pkgs self; }; - devShells.${system} = let - shells = self.devShells.${system}; - in { - c = pkgs.mkShell { - buildInputs = (with pkgs; [inotify-tools gdb gcc]) ++ (with self.packages.${system}; [c-hectic nvim-pager watch]); - PAGER = "${self.packages.${system}.nvim-pager}/bin/pager"; - }; - postgres-c = pkgs.mkShell { - buildInputs = (with pkgs; [ inotify-tools postgresql_15 ]) ++ (with self.packages.${system}; [ nvim-pager ]) ++ (with pkgs; [ gdb gcc ]); - PAGER = "${self.packages.${system}.nvim-pager}/bin/pager"; - - shellHook = '' - export PATH=${pkgs.gcc}/bin:$PATH - export PAGER="${self.packages.${system}.nvim-pager}/bin/pager" - ''; - }; - pure-c = pkgs.mkShell { - buildInputs = (with pkgs; [ inotify-tools ]) ++ (with self.packages.${system}; [ nvim-pager ]) ++ (with pkgs; [ gdb gcc binutils ]); - PAGER = "${self.packages.${system}.nvim-pager}/bin/pager"; - - shellHook = '' - export PATH=${pkgs.gcc}/bin:$PATH - - export PAGER="${self.packages.${system}.nvim-pager}/bin/pager" - ''; - }; - default = pkgs.mkShell { - buildInputs = - (with self.packages.${system}; [ - nvim-alias - #prettify-log - nvim-pager - ]) - ++ (with pkgs; [ - git - jq - yq-go - curl - (writeScriptBin "hemar-check" '' - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null vm-postgres 'zsh -c check' - '') - ]); - - # environment - PAGER = "${self.packages.${system}.nvim-pager}/bin/pager"; - }; - rust = let - rustToolchain = - if builtins.pathExists ./rust-toolchain.toml - then pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml - else pkgs.pkgsBuildHost.rust-bin.stable."1.81.0".default; - in - shells.default - // (pkgs.mkShell { - nativeBuildInputs = [ - rustToolchain - pkgs.pkg-config - ]; - }); - haskell = - shells.default - // (pkgs.mkShell { - buildInputs = [pkgs.stack]; - }); + devShells.${system} = { + c = import ./devshell/c.nix { inherit self system pkgs; }; + postgres-c = import ./devshell/postgres-c.nix { inherit self system pkgs; }; + pure-c = import ./devshell/pure-c.nix { inherit self system pkgs; }; + default = import ./devshell/default.nix { inherit self system pkgs; }; + rust = import ./devshell/rust.nix { inherit self system pkgs; }; + haskell = import ./devshell/haskell.nix { inherit self system pkgs; }; }; nixosConfigurations = { "devvm-manual|${system}" = import ./nixos/system/devvm-manual/default.nix { inherit flake self inputs system; };