You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# This file has been generated by Niv.let## The fetchers. fetch_<type> fetches specs of type <type>.#fetch_file=pkgs: name: spec:
letname'=sanitizeNamename+"-src";inifspec.builtinortruethenbuiltins_fetchurl{inherit(spec)urlsha256;name=name';}elsepkgs.fetchurl{inherit(spec)urlsha256;name=name';};fetch_tarball=pkgs: name: spec:
letname'=sanitizeNamename+"-src";inifspec.builtinortruethenbuiltins_fetchTarball{name=name';inherit(spec)urlsha256;}elsepkgs.fetchzip{name=name';inherit(spec)urlsha256;};fetch_git=name: spec:
letref=spec.refor(ifspec ? branchthen"refs/heads/${spec.branch}"elseifspec ? tagthen"refs/tags/${spec.tag}"elseabort"In git source '${name}': Please specify `ref`, `tag` or `branch`!");submodules=spec.submodulesorfalse;submoduleArg=letnixSupportsSubmodules=builtins.compareVersionsbuiltins.nixVersion"2.4">=0;emptyArgWithWarning=ifsubmodulesthenbuiltins.trace("The niv input \"${name}\" uses submodules "+"but your nix's (${builtins.nixVersion}) builtins.fetchGit "+"does not support them"){}else{};inifnixSupportsSubmodulesthen{inheritsubmodules;}elseemptyArgWithWarning;inbuiltins.fetchGit({url=spec.repo;inherit(spec)rev;inheritref;}//submoduleArg);fetch_local=spec: spec.path;fetch_builtin-tarball=name: throw''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. $ niv modify ${name} -a type=tarball -a builtin=true'';fetch_builtin-url=name: throw''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. $ niv modify ${name} -a type=file -a builtin=true'';## Various helpers## https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695sanitizeName=name:
(concatMapStrings(s: ifbuiltins.isListsthen"-"elses)(builtins.split"[^[:alnum:]+._?=-]+"((x: builtins.elemAt(builtins.match"\\.*(.*)"x)0)name)));# The set of packages used when specs are fetched using non-builtins.mkPkgs=sources: system:
letsourcesNixpkgs=import(builtins_fetchTarball{inherit(sources.nixpkgs)urlsha256;}){inheritsystem;};hasNixpkgsPath=builtins.any(x: x.prefix=="nixpkgs")builtins.nixPath;hasThisAsNixpkgsPath=<nixpkgs>==./.;inifbuiltins.hasAttr"nixpkgs"sourcesthensourcesNixpkgselseifhasNixpkgsPath&&!hasThisAsNixpkgsPaththenimport<nixpkgs>{}elseabort'' Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or add a package called "nixpkgs" to your sources.json. '';# The actual fetching function.fetch=pkgs: name: spec:
if!builtins.hasAttr"type"specthenabort"ERROR: niv spec ${name} does not have a 'type' attribute"elseifspec.type=="file"thenfetch_filepkgsnamespecelseifspec.type=="tarball"thenfetch_tarballpkgsnamespecelseifspec.type=="git"thenfetch_gitnamespecelseifspec.type=="local"thenfetch_localspecelseifspec.type=="builtin-tarball"thenfetch_builtin-tarballnameelseifspec.type=="builtin-url"thenfetch_builtin-urlnameelseabort"ERROR: niv spec ${name} has unknown type ${builtins.toJSONspec.type}";# If the environment variable NIV_OVERRIDE_${name} is set, then use# the path directly as opposed to the fetched source.replace=name: drv:
letsaneName=stringAsChars(c: if(builtins.match"[a-zA-Z0-9]"c)==nullthen"_"elsec)name;ersatz=builtins.getEnv"NIV_OVERRIDE_${saneName}";inifersatz==""thendrvelse# this turns the string into an actual Nix path (for both absolute and# relative paths)ifbuiltins.substring01ersatz=="/"then/.+ersatzelse/.+builtins.getEnv"PWD"+"/${ersatz}";# Ports of functions for older nix versions# a Nix version of mapAttrs if the built-in doesn't existmapAttrs=builtins.mapAttrsor(f: set: withbuiltins;listToAttrs(map(attr: {name=attr;value=fattrset.${attr};})(attrNamesset)));# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295range=first: last: iffirst>lastthen[]elsebuiltins.genList(n: first+n)(last-first+1);# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257stringToCharacters=s: map(p: builtins.substringp1s)(range0(builtins.stringLengths-1));# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269stringAsChars=f: s: concatStrings(mapf(stringToCharacterss));concatMapStrings=f: list: concatStrings(mapflist);concatStrings=builtins.concatStringsSep"";# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331optionalAttrs=cond: as: ifcondthenaselse{};# fetchTarball version that is compatible between all the versions of Nixbuiltins_fetchTarball={url,name?null,sha256}@attrs:
letinherit(builtins)lessThannixVersionfetchTarball;iniflessThannixVersion"1.12"thenfetchTarball({inheriturl;}//(optionalAttrs(name!=null){inheritname;}))elsefetchTarballattrs;# fetchurl version that is compatible between all the versions of Nixbuiltins_fetchurl={url,name?null,sha256}@attrs:
letinherit(builtins)lessThannixVersionfetchurl;iniflessThannixVersion"1.12"thenfetchurl({inheriturl;}//(optionalAttrs(name!=null){inheritname;}))elsefetchurlattrs;# Create the final "sources" from the configmkSources=config:
mapAttrs(name: spec:
ifbuiltins.hasAttr"outPath"specthenabort"The values in sources.json should not have an 'outPath' attribute"elsespec//{outPath=replacename(fetchconfig.pkgsnamespec);})config.sources;# The "config" used by the fetchersmkConfig={sourcesFile?ifbuiltins.pathExists./sources.jsonthen./sources.jsonelsenull,sources?ifsourcesFile==nullthen{}elsebuiltins.fromJSON(builtins.readFilesourcesFile),system?builtins.currentSystem,pkgs?mkPkgssourcessystem}: rec{# The sources, i.e. the attribute set of spec name to specinheritsources;# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchersinheritpkgs;};inmkSources(mkConfig{})//{__functor=_: settings: mkSources(mkConfigsettings);}
nix-build
touch test
nix-build -> builds again unnecessarily
The text was updated successfully, but these errors were encountered:
aMOPel
changed the title
[BUG] unnecessary rebuilds with mkPoetryApplication when non python files in projectDir change
[BUG] unnecessary rebuilds with mkPoetryApplication when any files in projectDir change
Jul 12, 2024
I think part of the problem for me was that this repo uses nixpkgs gitignore
which (probably) doesn't account for parent directory gitignore and global gitignore, leading to discrepancy of what you think is ignored and what poetry2nix thinks is ignored.
The other part was my ignorance to the fact that things have to be gitignored to not be part of the build.
So the example from above with touch test would still fail with my solution if it were touch src/test, if src/test was not gitignored.
You have to make sure everything that is not supposed to be part of the build is gitignored by the local .gitignore to get reproducible builds.
minimal-setup.tar.gz
Describe the issue
When setting
projectDir
inmkPoetryApplication
, the derivation depends on every file inprojectDir
.It would be better if it just depended on
I believe that would be the intended behavior but it seems the
cleanPythonSources { src = projectDir; }
is not working correctly.
Why does it matter?
Because there can be untracked files in the projectDir, like editor files, cache files, etc that cause rebuilds.
minimal example
code mostly copied from the blog post https://www.tweag.io/blog/2020-08-12-poetry2nix/
see attachment or:
minimal setup
imgapp/__init__.py
default.nix
:pyproject.toml
:poetry.lock
:nix/sources.json
nix/sources.nix
nix-build
touch test
nix-build
-> builds again unnecessarilyThe text was updated successfully, but these errors were encountered: