flake.nix: make users pass pkgs explicitly

This commit is contained in:
Alexander Sosedkin 2024-06-22 19:37:11 +02:00
parent 3d24441837
commit 54a535b91b
7 changed files with 29 additions and 21 deletions

View file

@ -2,6 +2,16 @@
## Release 24.05 (unreleased) ## Release 24.05 (unreleased)
### Compatibility considerations
* `nixOnDroidConfigurations` `pkgs` argument is now mandatory.
Put simply, if one's using a flake config, they need to add `nixpkgs` to
`outputs = { self, nixpkgs, ... }:` if it was previously missing,
then add a
`pkgs = import nixpkgs { system = "aarch64-linux"; };`
as an argument to `nixOnDroidConfiguration`.
If in doubt, refer to the `templates`.
## Release 23.11 ## Release 23.11
### New Options ### New Options

View file

@ -33,11 +33,6 @@
overlay = nixpkgs.lib.composeManyExtensions (import ./overlays); overlay = nixpkgs.lib.composeManyExtensions (import ./overlays);
pkgsPerSystem = system: import nixpkgs {
inherit system;
overlays = [ overlay ];
};
formatterPackArgsFor = forEachSystem (system: { formatterPackArgsFor = forEachSystem (system: {
inherit nixpkgs system; inherit nixpkgs system;
checkFiles = [ ./. ]; checkFiles = [ ./. ];
@ -74,22 +69,22 @@
formatter = forEachSystem (system: nix-formatter-pack.lib.mkFormatter formatterPackArgsFor.${system}); formatter = forEachSystem (system: nix-formatter-pack.lib.mkFormatter formatterPackArgsFor.${system});
lib.nixOnDroidConfiguration = lib.nixOnDroidConfiguration =
{ modules ? [ ] { pkgs
, system ? "aarch64-linux" , modules ? [ ]
, extraSpecialArgs ? { } , extraSpecialArgs ? { }
, pkgs ? pkgsPerSystem system
, home-manager-path ? home-manager.outPath , home-manager-path ? home-manager.outPath
# deprecated: # deprecated:
, config ? null , config ? null
, extraModules ? null , extraModules ? null
, system ? null # pkgs.system is used to detect user's arch
}: }:
if ! (builtins.elem system [ "aarch64-linux" "x86_64-linux" ]) then if ! (builtins.elem pkgs.system [ "aarch64-linux" "x86_64-linux" ]) then
throw throw
("${system} is not supported; aarch64-linux / x86_64-linux " + ("${pkgs.system} is not supported; aarch64-linux / x86_64-linux " +
"are the only currently supported system types") "are the only currently supported system types")
else else
pkgs.lib.throwIf pkgs.lib.throwIf
(config != null || extraModules != null) (config != null || extraModules != null || system != null)
'' ''
The 'nixOnDroidConfiguration' arguments The 'nixOnDroidConfiguration' arguments
@ -97,15 +92,17 @@
- 'extraModules' - 'extraModules'
- 'system' - 'system'
have been removed. Instead use the argument 'modules'. The have been removed.
'system' will be inferred by 'pkgs.system'. Instead of 'extraModules' use the argument 'modules'.
The 'system' will be inferred by 'pkgs.system',
so pass a 'pkgs = import nixpkgs { system = "aarch64-linux"; };'
See the 22.11 release notes for more. See the 22.11 release notes for more.
'' ''
(import ./modules { (import ./modules {
inherit extraSpecialArgs home-manager-path pkgs; inherit extraSpecialArgs home-manager-path pkgs;
config.imports = modules; config.imports = modules;
config.build.arch = config.build.arch =
nixpkgs.lib.strings.removeSuffix "-linux" system; nixpkgs.lib.strings.removeSuffix "-linux" pkgs.system;
isFlake = true; isFlake = true;
}); });

View file

@ -19,6 +19,7 @@
outputs = { self, nixpkgs, home-manager, nix-on-droid }: { outputs = { self, nixpkgs, home-manager, nix-on-droid }: {
nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration { nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration {
pkgs = import nixpkgs { system = "aarch64-linux"; };
modules = [ ./nix-on-droid.nix ]; modules = [ ./nix-on-droid.nix ];
}; };

View file

@ -13,7 +13,7 @@
outputs = { self, nixpkgs, nix-on-droid }: { outputs = { self, nixpkgs, nix-on-droid }: {
nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration { nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration {
system = "aarch64-linux"; pkgs = import nixpkgs { system = "aarch64-linux"; };
modules = [ ./nix-on-droid.nix ]; modules = [ ./nix-on-droid.nix ];
}; };

View file

@ -7,10 +7,10 @@
nix-on-droid.inputs.nixpkgs.follows = "nixpkgs"; nix-on-droid.inputs.nixpkgs.follows = "nixpkgs";
}; };
outputs = { nix-on-droid, ... }: { outputs = { nix-on-droid, nixpkgs, ... }: {
nixOnDroidConfigurations = { nixOnDroidConfigurations = {
default = nix-on-droid.lib.nixOnDroidConfiguration { default = nix-on-droid.lib.nixOnDroidConfiguration {
system = "<<SYSTEM>>"; pkgs = import nixpkgs { system = "<<SYSTEM>>"; };
modules = [ ./nix-on-droid.nix ]; modules = [ ./nix-on-droid.nix ];
}; };
}; };

View file

@ -11,10 +11,10 @@
}; };
}; };
outputs = { nix-on-droid, ... }: { outputs = { nix-on-droid, nixpkgs, ... }: {
nixOnDroidConfigurations = { nixOnDroidConfigurations = {
device = nix-on-droid.lib.nixOnDroidConfiguration { device = nix-on-droid.lib.nixOnDroidConfiguration {
system = "<<SYSTEM>>"; pkgs = import nixpkgs { system = "<<SYSTEM>>"; };
modules = [ ./nix-on-droid.nix ]; modules = [ ./nix-on-droid.nix ];
}; };
}; };

View file

@ -7,10 +7,10 @@
nix-on-droid.inputs.nixpkgs.follows = "nixpkgs"; nix-on-droid.inputs.nixpkgs.follows = "nixpkgs";
}; };
outputs = { nix-on-droid, ... }: { outputs = { nix-on-droid, nixpkgs, ... }: {
nixOnDroidConfigurations = { nixOnDroidConfigurations = {
device = nix-on-droid.lib.nixOnDroidConfiguration { device = nix-on-droid.lib.nixOnDroidConfiguration {
system = "<<SYSTEM>>"; pkgs = import nixpkgs { system = "<<SYSTEM>>"; };
modules = [ ./nix-on-droid.nix ]; modules = [ ./nix-on-droid.nix ];
}; };
}; };