Skip to content

Commit

Permalink
feat(flake): remove impurity, update nix-direnv
Browse files Browse the repository at this point in the history
Use path as an input that can be overriden automatically when direnv is
in use.
nix-direnv version present in .envrc has been updated, using watch_file on the flake is already handled.
  • Loading branch information
xarvex committed Aug 30, 2024
1 parent 4b35df0 commit bc38e56
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 20 deletions.
11 changes: 5 additions & 6 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url 'https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc' 'sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs='
if ! has nix_direnv_version || ! nix_direnv_version 3.0.5; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.5/direnvrc" "sha256-RuwIS+QKFj/T9M2TFXScjBsLR6V3A17YVoEW/Q6AZ1w="
fi

watch_file flake.nix
watch_file flake.lock

if ! use flake . --impure; then
DEVENV_ROOT_FILE="$(mktemp)"
printf %s "${PWD}" > "${DEVENV_ROOT_FILE}"
if ! use flake . --override-input devenv-root "file+file://${DEVENV_ROOT_FILE}"; then
printf '%s\n' "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
fi
37 changes: 25 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
inputs = {
devenv.url = "github:cachix/devenv";

devenv-root = {
url = "file+file:///dev/null";
flake = false;
};

flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
Expand Down Expand Up @@ -53,9 +58,14 @@
#
# Thank you! -Xarvex

name = "TagStudio";
devenv.root =
let
devenvRoot = builtins.readFile inputs.devenv-root.outPath;
in
# If not overriden (/dev/null), --impure is necessary.
pkgs.lib.mkIf (devenvRoot != "") devenvRoot;

dotenv.disableHint = true;
name = "TagStudio";

# Derived from previous flake iteration.
packages = (with pkgs; [
Expand Down

0 comments on commit bc38e56

Please sign in to comment.