-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add default.nix, add venv* to pytest's norecursedirs
- Loading branch information
Showing
3 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
argsOuter@{...}: | ||
let | ||
# specifying args defaults in this slightly non-standard way to allow us to include the default values in `args` | ||
args = rec { | ||
pkgs = import <nixpkgs> {}; | ||
pythonPackages = pkgs.python36Packages; | ||
forDev = true; | ||
localOverridesPath = ./local.nix; | ||
} // argsOuter; | ||
in (with args; { | ||
digitalMarketplaceUtilsEnv = (pkgs.stdenv.mkDerivation rec { | ||
name = "digitalmarketplace-utils-frontend-env"; | ||
shortName = "dm-utils"; | ||
buildInputs = [ | ||
pythonPackages.virtualenv | ||
] ++ pkgs.stdenv.lib.optionals forDev ([ | ||
] ++ pkgs.stdenv.lib.optionals pkgs.stdenv.isDarwin [ | ||
] | ||
); | ||
|
||
hardeningDisable = pkgs.stdenv.lib.optionals pkgs.stdenv.isDarwin [ "format" ]; | ||
|
||
VIRTUALENV_ROOT = "venv${pythonPackages.python.pythonVersion}"; | ||
VIRTUAL_ENV_DISABLE_PROMPT = "1"; | ||
SOURCE_DATE_EPOCH = "315532800"; | ||
|
||
# if we don't have this, we get unicode troubles in a --pure nix-shell | ||
LANG="en_GB.UTF-8"; | ||
|
||
shellHook = '' | ||
export PS1="\[\e[0;36m\](nix-shell\[\e[0m\]:\[\e[0;36m\]${shortName})\[\e[0;32m\]\u@\h\[\e[0m\]:\[\e[0m\]\[\e[0;36m\]\w\[\e[0m\]\$ " | ||
if [ ! -e $VIRTUALENV_ROOT ]; then | ||
${pythonPackages.virtualenv}/bin/virtualenv $VIRTUALENV_ROOT | ||
fi | ||
source $VIRTUALENV_ROOT/bin/activate | ||
make requirements${pkgs.stdenv.lib.optionalString forDev "-dev"} | ||
''; | ||
}).overrideAttrs (if builtins.pathExists localOverridesPath then (import localOverridesPath args) else (x: x)); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# default.nix calls out to the file local.nix if it exists, expecting a function which it will call, applying first | ||
# the args passed to the original default.nix and then `oldAttrs`, the attrset originally applied to mkDerivation. | ||
# | ||
# the function should return an attrset altered to the local user's desires, as they would wish to be applied to | ||
# mkDerivation to produce the env | ||
|
||
args: oldAttrs: oldAttrs // { | ||
# here we add some of our favourite packages to the environment which aren't necessarily to everyone's tastes | ||
buildInputs = oldAttrs.buildInputs ++ [ | ||
args.pkgs.vim | ||
args.pythonPackages.ipython | ||
]; | ||
|
||
shellHook = oldAttrs.shellHook + '' | ||
# PS1 can't be set as a normal derivation attr as it gets clobbered early on in the upstream shellHook script | ||
export PS1="⚡$PS1⚡" | ||
# inject some whimsy into our session - note here we access a package which we don't actually end up | ||
# explicitly exposing to the final environment | ||
${args.pkgs.fortune}/bin/fortune | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ max-line-length = 120 | |
exclude = ./venv* | ||
|
||
[pytest] | ||
norecursedirs = venv venv3 src | ||
norecursedirs = venv* src | ||
|