Skip to content

Commit

Permalink
WIP: Allow building a "store-only" nix
Browse files Browse the repository at this point in the history
This is a nix without the expression language or flakes, with just a few
commands.

TODO:

 - Do --help without libexper.

 - Dedup the two `main.cc`s

 - Dedup the two `nix.md`s

 - Dedup the two `help.md`s

Pop out parser

Fix completions
  • Loading branch information
Ericson2314 committed Dec 2, 2023
1 parent f7949fd commit d96e00b
Show file tree
Hide file tree
Showing 162 changed files with 829 additions and 1,858 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ perl/Makefile.config
# /src/libutil/
/tests/unit/libutil/libnixutil-tests

/src/nix/nix
/src/nix/store/mini-nix
/src/nix/full/nix

/src/nix/generated-doc
/src/nix/full/generated-doc

# /src/nix-env/
/src/nix-env/nix-env
Expand Down
19 changes: 15 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ include mk/build-dir.mk
-include $(buildprefix)Makefile.config
clean-files += $(buildprefix)Makefile.config

NIX_FULL ?= 1

ifeq ($(ENABLE_BUILD), yes)
makefiles = \
mk/precompiled-headers.mk \
local.mk \
src/libutil/local.mk \
src/libstore/local.mk \
src/libfetchers/local.mk \
src/libmain/local.mk \
src/libexpr/local.mk \
src/libcmd/local.mk \
src/libstore-cmd/local.mk \
src/nix/local.mk \
src/resolve-system-dependencies/local.mk \
scripts/local.mk \
Expand All @@ -22,25 +22,36 @@ makefiles = \
misc/systemd/local.mk \
misc/launchd/local.mk \
misc/upstart/local.mk
ifeq ($(NIX_FULL), 1)
makefiles += \
src/libfetchers/local.mk \
src/libexpr/local.mk \
src/libcmd/local.mk
endif
endif

ifeq ($(ENABLE_BUILD)_$(ENABLE_TESTS), yes_yes)
makefiles += \
tests/unit/libutil/local.mk \
tests/unit/libutil-support/local.mk \
tests/unit/libstore/local.mk \
tests/unit/libstore-support/local.mk \
tests/unit/libstore-support/local.mk
ifeq ($(NIX_FULL), 1)
makefiles += \
tests/unit/libexpr/local.mk \
tests/unit/libexpr-support/local.mk
endif
endif

ifeq ($(ENABLE_TESTS), yes)
ifeq ($(NIX_FULL), 1)
makefiles += \
tests/functional/local.mk \
tests/functional/ca/local.mk \
tests/functional/dyn-drv/local.mk \
tests/functional/test-libstoreconsumer/local.mk \
tests/functional/plugins/local.mk
endif
else
makefiles += \
mk/disable-tests.mk
Expand Down
8 changes: 8 additions & 0 deletions doc/manual/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ $(d)/src/SUMMARY.md: $(d)/src/SUMMARY.md.in $(d)/src/SUMMARY-rl-next.md $(d)/src
@cp $< $@
@$(call process-includes,$@,$@)

ifeq ($(NIX_FULL), 1)

$(d)/src/store/types: $(d)/nix.json $(d)/utils.nix $(d)/generate-store-info.nix $(d)/generate-store-types.nix $(d)/src/store/types/index.md.in $(doc_nix)
@# FIXME: build out of tree!
@rm -rf $@.tmp
Expand All @@ -122,10 +124,14 @@ $(d)/nix.json: $(doc_nix)
$(trace-gen) $(dummy-env) $(doc_nix) __dump-cli > $@.tmp
@mv $@.tmp $@

endif

$(d)/conf-file.json: $(doc_nix)
$(trace-gen) $(dummy-env) $(doc_nix) config show --json --experimental-features nix-command > $@.tmp
@mv $@.tmp $@

ifeq ($(NIX_FULL), 1)

$(d)/src/contributing/experimental-feature-descriptions.md: $(d)/xp-features.json $(d)/utils.nix $(d)/generate-xp-features.nix $(doc_nix)
@rm -rf $@ $@.tmp
$(trace-gen) $(nix-eval) --write-to $@.tmp --expr 'import doc/manual/generate-xp-features.nix (builtins.fromJSON (builtins.readFile $<))'
Expand Down Expand Up @@ -156,6 +162,8 @@ $(d)/language.json: $(doc_nix)
$(trace-gen) $(dummy-env) $(doc_nix) __dump-language > $@.tmp
@mv $@.tmp $@

endif

# Generate "Upcoming release" notes (or clear it and remove from menu)
$(d)/src/release-notes/rl-next.md: $(d)/rl-next $(d)/rl-next/*
@if type -p changelog-d > /dev/null; then \
Expand Down
3 changes: 1 addition & 2 deletions local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ GLOBAL_CXXFLAGS += -Wno-deprecated-declarations -Werror=switch
# Allow switch-enum to be overridden for files that do not support it, usually because of dependency headers.
ERROR_SWITCH_ENUM = -Werror=switch-enum

$(foreach i, config.h $(wildcard src/lib*/*.hh), \
$(eval $(call install-file-in, $(i), $(includedir)/nix, 0644)))
$(eval $(call install-file-in, config.h, $(includedir)/nix, 0644))

$(GCH): src/libutil/util.hh config.h

Expand Down
11 changes: 11 additions & 0 deletions src/libcmd/command-installable-value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

namespace nix {

InstallableValueCommand::InstallableValueCommand()
: SourceExprCommand()
{
expectArgs({
.label = "installable",
.optional = true,
.handler = {&_installable},
.completer = getCompleteInstallable(),
});
}

void InstallableValueCommand::run(ref<Store> store, ref<Installable> installable)
{
auto installableValue = InstallableValue::require(installable);
Expand Down
4 changes: 3 additions & 1 deletion src/libcmd/command-installable-value.hh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ namespace nix {
* An InstallableCommand where the single positional argument must be an
* InstallableValue in particular.
*/
struct InstallableValueCommand : InstallableCommand
struct InstallableValueCommand : AbstractInstallableCommand, SourceExprCommand
{
InstallableValueCommand();

/**
* Entry point to this command
*/
Expand Down
Loading

0 comments on commit d96e00b

Please sign in to comment.