Add --file argument for nix-on-droid

This commit is contained in:
Tobias Happ 2020-01-06 01:03:07 +01:00 committed by Alexander Sosedkin
parent 38e7b238ae
commit daf69b959d
3 changed files with 19 additions and 10 deletions

View file

@ -1,26 +1,26 @@
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
{ pkgs ? import <nixpkgs> { }, initialBuild ? false, config ? { } }:
{ pkgs ? import <nixpkgs> { }, config ? null }:
with pkgs.lib;
let
homeDir = builtins.getEnv "HOME";
configFile = homeDir + "/.config/nixpkgs/nix-on-droid.nix";
defaultConfigFile = "${builtins.getEnv "HOME"}/.config/nixpkgs/nix-on-droid.nix";
hasConfigFile = builtins.pathExists configFile;
configModule =
if config != null then config
else if builtins.pathExists defaultConfigFile then defaultConfigFile
else if pkgs.config ? nix-on-droid then pkgs.config.nix-on-droid
else throw "No config file found! Create one in ~/.config/nixpkgs/nix-on-droid.nix";
rawModule = evalModules {
modules = [
{
_module.args = { inherit pkgs; };
}
]
++ optional (!initialBuild && hasConfigFile) configFile
++ optional (!initialBuild && !hasConfigFile && pkgs.config ? nix-on-droid) pkgs.config.nix-on-droid
++ optional initialBuild config
++ import ./module-list.nix;
configModule
] ++ import ./module-list.nix;
};
failedAssertions = map (x: x.message) (filter (x: !x.assertion) rawModule.config.assertions);

View file

@ -23,6 +23,7 @@ function doHelp() {
echo " -h|--help Print this help"
echo " -n|--dry-run Do a dry run, only prints what actions would be taken"
echo " -v|--verbose Verbose output"
echo " -f|--file Path to config file"
echo
echo "Options passed on to nix build"
echo
@ -52,6 +53,10 @@ function doSwitch() {
PASSTHROUGH_OPTS+=(--show-trace)
fi
if [[ -n "$CONFIG_FILE" ]]; then
PASSTHROUGH_OPTS+=(--argstr config "$(realpath "$CONFIG_FILE")")
fi
echo "Building activation package..."
nix build \
--no-link \
@ -86,6 +91,7 @@ function doSwitchGeneration() {
COMMAND=
COMMAND_ARGS=()
PASSTHROUGH_OPTS=()
CONFIG_FILE=
while [[ $# -gt 0 ]]; do
opt="$1"
@ -94,6 +100,10 @@ while [[ $# -gt 0 ]]; do
generations|help|rollback|switch|switch-generation)
COMMAND="$opt"
;;
-f|--file)
CONFIG_FILE="$1"
shift
;;
-h|--help)
doHelp
exit 0

View file

@ -10,7 +10,6 @@ let
modules = import ../modules {
pkgs = nixpkgs;
initialBuild = true;
config = {
imports = [ ../modules/build/initial-build.nix ];