mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 11:36:07 +01:00
bootstrap: override flake inputs if needed
This commit is contained in:
parent
3629a12231
commit
1dc1cd67a4
2 changed files with 42 additions and 4 deletions
|
|
@ -4,6 +4,17 @@
|
|||
|
||||
with lib;
|
||||
|
||||
let
|
||||
defaultNixpkgsBranch = "nixos-22.05";
|
||||
defaultNixOnDroidBranch = "release-22.05";
|
||||
|
||||
defaultNixpkgsChannel = "https://nixos.org/channels/${defaultNixpkgsBranch}";
|
||||
defaultNixOnDroidChannel = "https://github.com/t184256/nix-on-droid/archive/${defaultNixOnDroidBranch}.tar.gz";
|
||||
|
||||
defaultNixpkgsFlake = "github:NixOS/nixpkgs/${defaultNixpkgsBranch}";
|
||||
defaultNixOnDroidFlake = "github:t184256/nix-on-droid/${defaultNixOnDroidBranch}";
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
###### interface
|
||||
|
|
@ -14,23 +25,35 @@ with lib;
|
|||
channel = {
|
||||
nixpkgs = mkOption {
|
||||
type = types.str;
|
||||
default = "https://nixos.org/channels/nixos-22.05";
|
||||
default = defaultNixpkgsChannel;
|
||||
description = "Channel URL for nixpkgs.";
|
||||
};
|
||||
|
||||
nix-on-droid = mkOption {
|
||||
type = types.str;
|
||||
default = "https://github.com/t184256/nix-on-droid/archive/release-22.05.tar.gz";
|
||||
default = defaultNixOnDroidChannel;
|
||||
description = "Channel URL for nix-on-droid.";
|
||||
};
|
||||
};
|
||||
|
||||
flake = {
|
||||
nixpkgs = mkOption {
|
||||
type = types.str;
|
||||
default = defaultNixpkgsFlake;
|
||||
description = "Flake URL for nixpkgs.";
|
||||
};
|
||||
|
||||
nix-on-droid = mkOption {
|
||||
type = types.str;
|
||||
default = "github:t184256/nix-on-droid/release-22.05";
|
||||
default = defaultNixOnDroidFlake;
|
||||
description = "Flake URL for nix-on-droid.";
|
||||
};
|
||||
|
||||
inputOverrides = mkEnableOption "" // {
|
||||
description = ''
|
||||
Whether to override the standard input URLs in the initial <filename>flake.nix</filename>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -41,7 +64,13 @@ with lib;
|
|||
|
||||
config = {
|
||||
|
||||
build.initialBuild = true;
|
||||
build = {
|
||||
initialBuild = true;
|
||||
|
||||
flake.inputOverrides =
|
||||
config.build.flake.nixpkgs != defaultNixpkgsFlake
|
||||
|| config.build.flake.nix-on-droid != defaultNixOnDroidFlake;
|
||||
};
|
||||
|
||||
# /etc/group and /etc/passwd need to be build on target machine because
|
||||
# uid and gid need to be determined.
|
||||
|
|
|
|||
|
|
@ -78,6 +78,15 @@ writeText "login-inner" ''
|
|||
echo "Installing flake from default template..."
|
||||
${nixCmd} flake new ${config.user.home}/.config/nix-on-droid --template ${config.build.flake.nix-on-droid}
|
||||
|
||||
${lib.optionalString config.build.flake.inputOverrides ''
|
||||
echo "Overriding input urls in flake..."
|
||||
${nixCmd} run nixpkgs#gnused -- \
|
||||
-i \
|
||||
-e 's,\"github:NixOS/nixpkgs.*\",\"${config.build.flake.nixpkgs}\",' \
|
||||
-e 's,\"github:t184256/nix-on-droid.*\",\"${config.build.flake.nix-on-droid}\",' \
|
||||
"${config.user.home}/.config/nix-on-droid/flake.nix"
|
||||
''}
|
||||
|
||||
echo "Installing first nix-on-droid generation..."
|
||||
${nixCmd} run ${config.build.flake.nix-on-droid} -- switch --flake ${config.user.home}/.config/nix-on-droid#deviceName
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue