Update nix-develop and nix-direnv

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-02-21 09:19:44 +00:00
parent 75a0a59c3d
commit 0235b1146f
5 changed files with 64 additions and 10 deletions

View File

@@ -35,7 +35,16 @@
done
if [[ -z "$devshell" ]]; then
if [ ! -f flake.nix ]; then cp "${./template.nix}" flake.nix; fi
if [ ! -f flake.nix ]; then
cp "${./template.nix}" flake.nix
chmod 755 flake.nix
fi
if [ ! treefmt.nix ]; then
cp "${./treefmt.nix}" treefmt.nix
chmod 755 treefmt.nix
fi
nix develop -c "$SHELL"
else
nix develop self#"$devshell" -c "$SHELL"

View File

@@ -8,21 +8,35 @@
};
flake-utils = {
url = "github:numtide/flake-utils";
type = "github";
owner = "numtide";
repo = "flake-utils";
ref = "main";
};
treefmt-nix = {
type = "github";
owner = "numtide";
repo = "treefmt-nix";
ref = "main";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ nixpkgs, ... }@inputs:
{ self, nixpkgs, ... }@inputs:
inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
treefmt = inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
in
{
devShells.default = pkgs.mkShell { packages = [ ]; };
devShells.default = pkgs.mkShell { packages = with pkgs; [ ]; };
formatter = pkgs.nixfmt-rfc-style;
formatter = treefmt.config.build.wrapper;
checks.formatting = treefmt.config.build.check self;
}
);
}

View File

@@ -0,0 +1,19 @@
{ ... }:
{
projectRootFile = "flake.nix";
programs = {
nixfmt = {
enable = true;
strict = true;
};
};
settings = {
global = {
excludes = [
".envrc"
];
};
};
}

View File

@@ -49,8 +49,21 @@
done
if [[ -z "$devshell" ]]; then
echo "use flake" > .envrc
if [ ! -f flake.nix ]; then cp "${../nix-develop/template.nix}" flake.nix; fi
if "$hide"; then
echo "use flake path:." > .envrc;
else
echo "use flake" > .envrc;
fi
if [ ! -f flake.nix ]; then
cp "${../nix-develop/template.nix}" flake.nix
chmod 755 flake.nix
fi
if [ ! -f treefmt.nix ]; then
cp "${../nix-develop/treefmt.nix}" treefmt.nix
chmod 755 treefmt.nix
fi
else
echo "use flake self#$devshell" > .envrc
fi
@@ -62,6 +75,7 @@
if [ -z "$devshell" ]; then
if ! grep -q "^flake.nix$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.nix" >> "$top/.git/info/exclude"; fi
if ! grep -q "^flake.lock$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.lock" >> "$top/.git/info/exclude"; fi
if ! grep -q "^treefmt.nix$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "treefmt.nix" >> "$top/.git/info/exclude"; fi
fi
fi