From 962390c0b2e90c1c85abfe69b8b76fd7ef3925ee Mon Sep 17 00:00:00 2001 From: "Daniel B. Hill" Date: Wed, 12 Jan 2022 00:26:05 +1300 Subject: [PATCH] Simplify Nix(OS) development Signed-off-by: Daniel B. Hill --- default.nix | 26 ++++++-------------------- nix/overlay.nix | 1 - shell.nix | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 shell.nix diff --git a/default.nix b/default.nix index 48f2aa9..a693194 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,5 @@ { lib -, filter - +, doCheck ? true , stdenv , pkg-config , attr @@ -20,8 +19,7 @@ , docutils , nixosTests -, lastModified -, versionString ? lastModified +, versionString ? "0.1" , inShell ? false , debugMode ? inShell @@ -39,20 +37,8 @@ stdenv.mkDerivation { version = "v0.1-flake-${versionString}"; VERSION = "v0.1-flake-${versionString}"; - - src = filter.filter { - name = "bcachefs-tools"; - root = ./.; - exclude = [ - ./rust-src - - ./.git - ./nix - - ./flake.nix - ./flake.lock - ]; - }; + + src = (lib.cleanSource (builtins.path { name = "bcachefs-tools-src"; path = ./. ;} )); postPatch = "patchShebangs --build doc/macro2rst.py"; @@ -95,7 +81,7 @@ stdenv.mkDerivation { "INITRAMFS_DIR=${placeholder "out"}/etc/initramfs-tools" ]; - doCheck = true; # needs bcachefs module loaded on builder + doCheck = doCheck; # needs bcachefs module loaded on builder checkInputs = [ python39Packages.pytest @@ -116,7 +102,7 @@ stdenv.mkDerivation { rm tests/test_fuse.py ''; - dontStrip = debugMode == true; + dontStrip = debugMode; passthru = { bcachefs_revision = let file = builtins.readFile ./.bcachefs_revision; diff --git a/nix/overlay.nix b/nix/overlay.nix index 42d3fb2..8138f20 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -4,7 +4,6 @@ final: prev: { tools = final.callPackage ../default.nix { testWithValgrind = false; filter = filter.lib; - lastModified = builtins.substring 0 8 self.lastModifiedDate; versionString = self.version; }; toolsValgrind = final.bcachefs.tools.override { diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..fc7929d --- /dev/null +++ b/shell.nix @@ -0,0 +1,18 @@ +{ kversion ? "linux_5_15" +, pkgs ? import {} }: + +with pkgs; + +let + tools = pkgs.callPackage ./default.nix { doCheck = false ;} ; +in +mkShell { + buildInputs = [ + linuxKernel.packages.${kversion}.perf + gdb + ccls # code completion in neovim/emacs + ]; + inputsFrom = [ + tools + ]; +} -- 2.39.2