aboutsummaryrefslogtreecommitdiff
path: root/src/nix/command.hh
AgeCommit message (Collapse)Author
2020-12-03Allow registering subcommands of subcommandsEelco Dolstra
2020-08-17Add 'nix dump-args' to dump all commands/flags for manpage generationEelco Dolstra
2020-07-31nix/build: add `--rebuild` optionMaximilian Bosch
Occasionally, `nix-build --check` is fairly helpful and I'd like to be able to use this feature for flakes that need to be built with `nix build` as well.
2020-07-16Add command 'nix profile diff-closure'Eelco Dolstra
This shows all changes between generations of a profile. E.g. $ nix profile diff-closures --profile /nix/var/nix/profiles/system Generation 654 -> 655: nix: 2.4pre20200617_5d69bbf → 2.4pre20200701_6ff9aa8, +42.2 KiB Generation 655 -> 656: blender-bin: 2.83.0 → 2.83.1, -294.2 KiB Generation 656 -> 657: curl: 7.68.0 → 7.70.0, +19.1 KiB firmware-linux-nonfree: 2020-01-22 → 2020-05-19, +30827.7 KiB ibus: -21.8 KiB initrd-linux: 5.4.46 → 5.4.49 ...
2020-07-15nix: Add --derivation flag to operate on .drv pathsEelco Dolstra
For instance, 'nix why-depends --use-derivation nixpkgs#hello nixpkgs#glibc' shows why hello's .drv depends on glibc's .drv.
2020-07-15Clean up RealiseModeEelco Dolstra
2020-06-08Add completion for --update-inputEelco Dolstra
2020-06-05Fix completion of --templateEelco Dolstra
2020-05-11nix flake: Add completion supportEelco Dolstra
2020-05-11Add completion for installablesEelco Dolstra
This completes flakerefs using the registry (e.g. 'nix<TAB>' => 'nix nixpkgs') and flake output attributes by evaluating the flake (e.g. 'dwarffs#nix<TAB>' => 'dwarffs#nixosModules').
2020-05-11CleanupEelco Dolstra
2020-05-05Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-05-05nix --help: Group commandsEelco Dolstra
2020-04-16Use RootValueEelco Dolstra
2020-04-13SourceExprCommand: allocate the vSourceExpr via uncollectable memoryAndreas Rammhold
Previously the memory would occasionally be collected during eval since the GC doesn't consider the member variable as alive / doesn't scan the region of memory where the pointer lives. By using the traceable_allocator<T> allocator provided by Boehm GC we can ensure the memory isn't collected. It should be properly freed when SourceExprCommand goes out of scope.
2020-04-01Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-03-30Backport 'nix dev-shell' from the flakes branchEelco Dolstra
This also adds a '--profile' option to 'nix build' (replacing 'nix-env --set').
2020-03-24nix edit: Support non-derivation attributesEelco Dolstra
E.g. $ nix edit .#nixosConfigurations.bla now works. (cherry picked from commit d2032edb2f86e955a8a7724a27c0c3225f386500)
2020-01-29Clean up the lock file handling flagsEelco Dolstra
Added a flag --no-update-lock-file to barf if the lock file needs any changes. This is useful for CI systems if you're building a checkout. Fixes #2947. Renamed --no-save-lock-file to --no-write-lock-file. It is now a fatal error if the lock file needs changes but --no-write-lock-file is not given.
2020-01-29Add flag --override-input to override specific lock file entriesEelco Dolstra
E.g. $ nix flake update ~/Misc/eelco-configurations/hagbard \ --override-input 'dwarffs/nixpkgs' ../my-nixpkgs overrides the 'nixpkgs' input of the 'dwarffs' input of the top-level flake. Fixes #2837.
2020-01-24HandleLockFile -> LockFileModeEelco Dolstra
2019-12-14Fix InstallableCommandEelco Dolstra
2019-12-11Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2019-12-10Make the Store API more type-safeEelco Dolstra
Most functions now take a StorePath argument rather than a Path (which is just an alias for std::string). The StorePath constructor ensures that the path is syntactically correct (i.e. it looks like <store-dir>/<base32-hash>-<name>). Similarly, functions like buildPaths() now take a StorePathWithOutputs, rather than abusing Path by adding a '!<outputs>' suffix. Note that the StorePath type is implemented in Rust. This involves some hackery to allow Rust values to be used directly in C++, via a helper type whose destructor calls the Rust type's drop() function. The main issue is the dynamic nature of C++ move semantics: after we have moved a Rust value, we should not call the drop function on the original value. So when we move a value, we set the original value to bitwise zero, and the destructor only calls drop() if the value is not bitwise zero. This should be sufficient for most types. Also lots of minor cleanups to the C++ API to make it more modern (e.g. using std::optional and std::string_view in some places).
2019-12-05Make subcommand construction in MultiCommand lazyEelco Dolstra
(cherry picked from commit a0de58f471c9087d8e6cc60a6078f9940a125b15)
2019-12-05Move Command and MultiCommand to libutilEelco Dolstra
(cherry picked from commit f70434b1fbbdb0e188718f0c55a8156a7aa08744)
2019-12-05MultiCommand: Simplify constructionEelco Dolstra
(cherry picked from commit 15a16e5c05d547ec07170df2392263e5e891447b)
2019-12-04Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2019-12-02Merge branch 'run-environment' of https://github.com/mkenigs/nix into flakesEelco Dolstra
2019-11-27nix: Add --expr flagEelco Dolstra
This replaces the '(...)' installable syntax, which is not very discoverable. The downside is that you can't have multiple expressions or mix expressions and other installables.
2019-11-26Fix clang warningsEelco Dolstra
2019-11-08Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2019-11-08Move editorFor srom libutil to nixEelco Dolstra
libutil should not depend on libexpr.
2019-11-07Factor out code to handle environment in run into MixEnvironmentmatthew
2019-11-04Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2019-10-31Minor updates to inline commentsBenjamin Hipple
Add missing docstring on InstallableCommand. Also, some of these were wrapped when they're right next to a line longer than the unwrapped line, so we can just unwrap them to save vertical space.
2019-10-22Add start of 'nix profile' commandEelco Dolstra
2019-10-21Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2019-10-21Allow content-addressable paths to have referencesEelco Dolstra
This adds a command 'nix make-content-addressable' that rewrites the specified store paths into content-addressable paths. The advantage of such paths is that 1) they can be imported without signatures; 2) they can enable deduplication in cases where derivation changes do not cause output changes (apart from store path hashes). For example, $ nix make-content-addressable -r nixpkgs.cowsay rewrote '/nix/store/g1g31ah55xdia1jdqabv1imf6mcw0nb1-glibc-2.25-49' to '/nix/store/48jfj7bg78a8n4f2nhg269rgw1936vj4-glibc-2.25-49' ... rewrote '/nix/store/qbi6rzpk0bxjw8lw6azn2mc7ynnn455q-cowsay-3.03+dfsg1-16' to '/nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16' We can then copy the resulting closure to another store without signatures: $ nix copy --trusted-public-keys '' ---to ~/my-nix /nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16 In order to support self-references in content-addressable paths, these paths are hashed "modulo" self-references, meaning that self-references are zeroed out during hashing. Somewhat annoyingly, this means that the NAR hash stored in the Nix database is no longer necessarily equal to the output of "nix hash-path"; for content-addressable paths, you need to pass the --modulo flag: $ nix path-info --json /nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16 | jq -r .[].narHash sha256:0ri611gdilz2c9rsibqhsipbfs9vwcqvs811a52i2bnkhv7w9mgw $ nix hash-path --type sha256 --base32 /nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16 1ggznh07khq0hz6id09pqws3a8q9pn03ya3c03nwck1kwq8rclzs $ nix hash-path --type sha256 --base32 /nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16 --modulo iq6g2x4q62xp7y7493bibx0qn5w7xz67 0ri611gdilz2c9rsibqhsipbfs9vwcqvs811a52i2bnkhv7w9mgw
2019-10-15Support non-x86_64-linux system types in flakesEelco Dolstra
A command like $ nix run nixpkgs#hello will now build the attribute 'packages.${system}.hello' rather than 'packages.hello'. Note that this does mean that the flake needs to export an attribute for every system type it supports, and you can't build on unsupported systems. So 'packages' typically looks like this: packages = nixpkgs.lib.genAttrs ["x86_64-linux" "i686-linux"] (system: { hello = ...; }); The 'checks', 'defaultPackage', 'devShell', 'apps' and 'defaultApp' outputs similarly are now attrsets that map system types to derivations/apps. 'nix flake check' checks that the derivations for all platforms evaluate correctly, but only builds the derivations in 'checks.${system}'. Fixes #2861. (That issue also talks about access to ~/.config/nixpkgs and --arg, but I think it's reasonable to say that flakes shouldn't support those.) The alternative to attribute selection is to pass the system type as an argument to the flake's 'outputs' function, e.g. 'outputs = { self, nixpkgs, system }: ...'. However, that approach would be at odds with hermetic evaluation and make it impossible to enumerate the packages provided by a flake.
2019-10-14Move code aroundEelco Dolstra
2019-09-02Shut up some clang warningsEelco Dolstra
2019-07-12nix dev-shell: Make it possible to enter a profileEelco Dolstra
For example: $ nix dev-shell --profile /tmp/my-shell dwarffs (later) $ nix dev-shell /tmp/my-shell
2019-07-12nix build: Add '--profile' flagEelco Dolstra
This replaces 'nix-env --set'. For example: $ nix build --profile /nix/var/nix/profiles/system \ ~/Misc/eelco-configurations:nixosConfigurations.vyr.config.system.build.toplevel updates the NixOS system profile from a flake. This could have been a separate command (e.g. 'nix set-profile') but 1) '--profile' is pretty similar to '--out-link'; and 2) '--profile' could be useful for other command (like 'nix dev-shell').
2019-06-18Make subcommand construction in MultiCommand lazyEelco Dolstra
2019-06-17nix flake check: Check appsEelco Dolstra
2019-06-17nix app: Search for installable in the 'apps' outputEelco Dolstra
I.e. you can write $ nix app blender-bin:blender_2_80 which is equivalent to $ nix app blender-bin:apps.blender_2_80
2019-06-03Add 'nix app' commandEelco Dolstra
This is like 'nix run', except that the command to execute is defined in a flake output, e.g. defaultApp = { type = "app"; program = "${packages.blender_2_80}/bin/blender"; }; Thus you can do $ nix app blender-bin to start Blender from the 'blender-bin' flake. In the future, we can extend this with sandboxing. (For example we would want to be able to specify that Blender should not have network access by default and should only have access to certain paths in the user's home directory.)
2019-05-29Put flake-related stuff in its own namespaceEelco Dolstra
2019-05-22Move flake-related flags into a separate classEelco Dolstra
Also, rename --dont-save-lock-file to --no-save-lock-file and change noRegistries to useRegistries.