mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
Merge 357af61846 into 3aab6a9ec4
This commit is contained in:
commit
b3abd1bf27
6 changed files with 113 additions and 136 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Copyright (c) 2019-2023, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||
|
||||
{ pkgs, home-manager, nmdSrc }:
|
||||
{ pkgs, nixpkgs, home-manager, nmdSrc }:
|
||||
|
||||
let
|
||||
nmd = import nmdSrc { inherit pkgs; };
|
||||
|
|
@ -14,7 +14,7 @@ let
|
|||
};
|
||||
|
||||
modules = import ../modules/module-list.nix {
|
||||
inherit pkgs;
|
||||
inherit pkgs nixpkgs;
|
||||
home-manager-path = home-manager.outPath;
|
||||
isFlake = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, nixpkgs-for-bootstrap, home-manager, nix-formatter-pack, nmd }:
|
||||
outputs = { self, nixpkgs, nixpkgs-for-bootstrap, home-manager, nix-formatter-pack, nmd }@inputs:
|
||||
let
|
||||
forEachSystem = nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" ];
|
||||
|
||||
|
|
@ -80,6 +80,7 @@
|
|||
{ modules ? [ ]
|
||||
, extraSpecialArgs ? { }
|
||||
, pkgs ? pkgs'
|
||||
, nixpkgs ? inputs.nixpkgs
|
||||
, home-manager-path ? home-manager.outPath
|
||||
# deprecated:
|
||||
, config ? null
|
||||
|
|
@ -103,7 +104,7 @@
|
|||
See the 22.11 release notes for more.
|
||||
''
|
||||
(import ./modules {
|
||||
inherit extraSpecialArgs home-manager-path pkgs;
|
||||
inherit extraSpecialArgs home-manager-path nixpkgs pkgs;
|
||||
config.imports = modules;
|
||||
isFlake = true;
|
||||
});
|
||||
|
|
@ -118,7 +119,7 @@
|
|||
};
|
||||
|
||||
docs = import ./docs {
|
||||
inherit home-manager;
|
||||
inherit nixpkgs home-manager;
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
nmdSrc = nmd;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
{ config ? null
|
||||
, extraSpecialArgs ? { }
|
||||
, pkgs ? import <nixpkgs> { }
|
||||
, nixpkgs ? <nixpkgs>
|
||||
, home-manager-path ? <home-manager>
|
||||
, isFlake ? false
|
||||
}:
|
||||
|
|
@ -21,7 +22,7 @@ let
|
|||
|
||||
rawModule = evalModules {
|
||||
modules = [ configModule ] ++ nodModules;
|
||||
specialArgs = extraSpecialArgs;
|
||||
specialArgs = { inherit nixpkgs; } // extraSpecialArgs;
|
||||
};
|
||||
|
||||
failedAssertions = map (x: x.message) (filter (x: !x.assertion) rawModule.config.assertions);
|
||||
|
|
|
|||
44
modules/environment/nix-channel.nix
Normal file
44
modules/environment/nix-channel.nix
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||
|
||||
# Based on
|
||||
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/config/nix-channel.nix
|
||||
# (Copyright (c) 2003-2022 Eelco Dolstra and the Nixpkgs/NixOS contributors,
|
||||
# licensed under MIT License as well)
|
||||
|
||||
{ config, lib, pkgs, nixpkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.nix;
|
||||
renameNixOpt = old: new:
|
||||
(mkRenamedOptionModule [ "nix" old ] [ "nix" new ]);
|
||||
in
|
||||
|
||||
{
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
nix = {
|
||||
nixPath = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
The default Nix expression search path, used by the Nix
|
||||
evaluator to look up paths enclosed in angle brackets
|
||||
(e.g. <literal><nixpkgs></literal>).
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
###### implementation
|
||||
|
||||
config = {
|
||||
environment.sessionVariables.NIX_PATH = concatStringsSep ":" cfg.nixPath;
|
||||
};
|
||||
|
||||
}
|
||||
21
modules/environment/nix-flakes.nix
Normal file
21
modules/environment/nix-flakes.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||
|
||||
# Based on
|
||||
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/config/nix-flakes.nix
|
||||
# (Copyright (c) 2003-2022 Eelco Dolstra and the Nixpkgs/NixOS contributors,
|
||||
# licensed under MIT License as well)
|
||||
|
||||
{ config, lib, pkgs, nixpkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.nix;
|
||||
in
|
||||
|
||||
{
|
||||
imports = [
|
||||
# Use options and config from upstream nix-flakes.nix
|
||||
"${nixpkgs}/nixos/modules/config/nix-flakes.nix"
|
||||
];
|
||||
}
|
||||
|
|
@ -1,26 +1,33 @@
|
|||
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||
|
||||
# Based on
|
||||
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/misc/nix-daemon.nix
|
||||
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/system/nix-daemon.nix
|
||||
# and
|
||||
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/config/nix.nix
|
||||
# (Copyright (c) 2003-2022 Eelco Dolstra and the Nixpkgs/NixOS contributors,
|
||||
# licensed under MIT License as well)
|
||||
|
||||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, pkgs, nixpkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.nix;
|
||||
renameNixOpt = old: new:
|
||||
(mkRenamedOptionModule [ "nix" old ] [ "nix" new ]);
|
||||
mkRenamedOptionModuleWith {
|
||||
sinceRelease = 2205;
|
||||
from = [ "nix" old ];
|
||||
to = [ "nix" "settings" new ];
|
||||
};
|
||||
in
|
||||
|
||||
{
|
||||
# Backward-compatibility with the NixOS options.
|
||||
imports = [
|
||||
(renameNixOpt "binaryCaches" "substituters")
|
||||
(renameNixOpt "binaryCachePublicKeys" "trustedPublicKeys")
|
||||
(renameNixOpt "extraConfig" "extraOptions")
|
||||
# Use options and config from upstream nix.nix
|
||||
"${nixpkgs}/nixos/modules/config/nix.nix"
|
||||
# Backward-compatibility with pre-`settings` options.
|
||||
(renameNixOpt "substituters" "substituters")
|
||||
(renameNixOpt "trustedPublicKeys" "trusted-public-keys")
|
||||
];
|
||||
|
||||
###### interface
|
||||
|
|
@ -28,6 +35,19 @@ in
|
|||
options = {
|
||||
|
||||
nix = {
|
||||
|
||||
## From nix-daemon.nix
|
||||
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to enable Nix.
|
||||
Disabling Nix is not supported in NixOnDroid. This option is here to
|
||||
make it compatible to the upstream NixOS modules.
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.nix;
|
||||
|
|
@ -37,97 +57,6 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
nixPath = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
The default Nix expression search path, used by the Nix
|
||||
evaluator to look up paths enclosed in angle brackets
|
||||
(e.g. <literal><nixpkgs></literal>).
|
||||
'';
|
||||
};
|
||||
|
||||
registry = mkOption {
|
||||
type = types.attrsOf (types.submodule (
|
||||
let
|
||||
referenceAttrs = with types; attrsOf (oneOf [
|
||||
str
|
||||
int
|
||||
bool
|
||||
package
|
||||
]);
|
||||
in
|
||||
{ config, name, ... }:
|
||||
{
|
||||
options = {
|
||||
from = mkOption {
|
||||
type = referenceAttrs;
|
||||
example = { type = "indirect"; id = "nixpkgs"; };
|
||||
description = "The flake reference to be rewritten.";
|
||||
};
|
||||
to = mkOption {
|
||||
type = referenceAttrs;
|
||||
example = { type = "github"; owner = "my-org"; repo = "my-nixpkgs"; };
|
||||
description = "The flake reference <option>from</option> is rewritten to.";
|
||||
};
|
||||
flake = mkOption {
|
||||
type = types.nullOr types.attrs;
|
||||
default = null;
|
||||
example = literalExpression "nixpkgs";
|
||||
description = ''
|
||||
The flake input <option>from</option> is rewritten to.
|
||||
'';
|
||||
};
|
||||
exact = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether the <option>from</option> reference needs to match exactly. If set,
|
||||
a <option>from</option> reference like <literal>nixpkgs</literal> does not
|
||||
match with a reference like <literal>nixpkgs/nixos-20.03</literal>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
config = {
|
||||
from = mkDefault { type = "indirect"; id = name; };
|
||||
to = mkIf (config.flake != null) (mkDefault
|
||||
{
|
||||
type = "path";
|
||||
path = config.flake.outPath;
|
||||
} // filterAttrs
|
||||
(n: _: n == "lastModified" || n == "rev" || n == "revCount" || n == "narHash")
|
||||
config.flake);
|
||||
};
|
||||
}
|
||||
));
|
||||
default = { };
|
||||
description = "A system-wide flake registry.";
|
||||
};
|
||||
|
||||
substituters = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of URLs of substituters. The official NixOS and Nix-on-Droid
|
||||
substituters are added by default.
|
||||
'';
|
||||
};
|
||||
|
||||
trustedPublicKeys = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of public keys. When paths are copied from another Nix store (such as a
|
||||
binary cache), they must be signed with one of these keys. The official NixOS
|
||||
and Nix-on-Droid public keys are added by default.
|
||||
'';
|
||||
};
|
||||
|
||||
extraOptions = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = "Extra config to be appended to <filename>/etc/nix/nix.conf</filename>.";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
|
@ -135,37 +64,18 @@ in
|
|||
|
||||
###### implementation
|
||||
|
||||
config = mkMerge [
|
||||
{
|
||||
environment.etc = {
|
||||
"nix/nix.conf".text = ''
|
||||
sandbox = false
|
||||
substituters = ${concatStringsSep " " cfg.substituters}
|
||||
trusted-public-keys = ${concatStringsSep " " cfg.trustedPublicKeys}
|
||||
${cfg.extraOptions}
|
||||
'';
|
||||
|
||||
"nix/registry.json".text = builtins.toJSON {
|
||||
version = 2;
|
||||
flakes = mapAttrsToList (_n: v: { inherit (v) from to exact; }) cfg.registry;
|
||||
};
|
||||
};
|
||||
|
||||
nix = {
|
||||
substituters = [
|
||||
"https://cache.nixos.org"
|
||||
"https://nix-on-droid.cachix.org"
|
||||
];
|
||||
trustedPublicKeys = [
|
||||
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
|
||||
"nix-on-droid.cachix.org-1:56snoMJTXmDRC1Ei24CmKoUqvHJ9XCp+nidK7qkMQrU="
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
(mkIf (cfg.nixPath != [ ]) {
|
||||
environment.sessionVariables.NIX_PATH = concatStringsSep ":" cfg.nixPath;
|
||||
})
|
||||
];
|
||||
config = {
|
||||
nix = {
|
||||
enable = true;
|
||||
settings.substituters = [
|
||||
"https://cache.nixos.org"
|
||||
"https://nix-on-droid.cachix.org"
|
||||
];
|
||||
settings.trusted-public-keys = [
|
||||
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
|
||||
"nix-on-droid.cachix.org-1:56snoMJTXmDRC1Ei24CmKoUqvHJ9XCp+nidK7qkMQrU="
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue