Skip to content

Commit

Permalink
(chore): add dev menu
Browse files Browse the repository at this point in the history
  • Loading branch information
rupurt committed Aug 1, 2024
1 parent 8aa8cb9 commit 3eebf20
Show file tree
Hide file tree
Showing 11 changed files with 918 additions and 625 deletions.
19 changes: 19 additions & 0 deletions .direnv/bin/nix-direnv-reload
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -e
if [[ ! -d "/home/alex/workspace/rupurt/typerutils" ]]; then
echo "Cannot find source directory; Did you move it?"
echo "(Looking for "/home/alex/workspace/rupurt/typerutils")"
echo 'Cannot force reload with this script - use "direnv reload" manually and then try again'
exit 1
fi

# rebuild the cache forcefully
_nix_direnv_force_reload=1 direnv exec "/home/alex/workspace/rupurt/typerutils" true

# Update the mtime for .envrc.
# This will cause direnv to reload again - but without re-building.
touch "/home/alex/workspace/rupurt/typerutils/.envrc"

# Also update the timestamp of whatever profile_rc we have.
# This makes sure that we know we are up to date.
touch -r "/home/alex/workspace/rupurt/typerutils/.envrc" "/home/alex/workspace/rupurt/typerutils/.direnv"/*.rc
19 changes: 19 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

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

export APP_NAME="typerutils"
export REPO="$(expand_path .)"
export LOCAL="$REPO/.local"
export LOCAL_ENVRC="$LOCAL/dev.envrc"
export SCRIPTS="$REPO/scripts"

source_env_if_exists $LOCAL_ENVRC

PATH_add bin

if [[ $AUTO_ACTIVATE != "false" ]]; then
use flake .
fi
54 changes: 54 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
config,
lib,
dream2nix,
...
}: let
pyproject = lib.importTOML (config.mkDerivation.src + /pyproject.toml);
in {
imports = [
dream2nix.modules.dream2nix.pip
dream2nix.modules.dream2nix.flags
];

deps = {
nixpkgs,
self,
...
}: {
stdenv = nixpkgs.stdenv;
python = nixpkgs.python311;
};

flagsOffered = {
groupDev = "include dependencies for optional [dev] pip group";
};

flags = {
groupDev = lib.mkDefault false;
};

inherit (pyproject.project) name version;

mkDerivation = {
src = ./.;
buildInputs = [
config.deps.python
];
};

buildPythonPackage = {
format = lib.mkForce "pyproject";
};

pip = {
requirementsList =
pyproject.build-system.requires
or []
++ pyproject.project.dependencies
++ lib.optionals (config.flags.groupDev) pyproject.project.optional-dependencies.dev;
flattenDependencies = true;
overrideAll.deps.python = lib.mkForce config.deps.python;
overrides = { };
};
}
101 changes: 76 additions & 25 deletions flake.lock

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

Loading

0 comments on commit 3eebf20

Please sign in to comment.