mirror of
https://github.com/nix-community/flakelight.git
synced 2024-11-21 23:13:09 +01:00
Add support for configuring legacyPackages
This commit is contained in:
parent
086393b47b
commit
1fa95e0d84
38
API_GUIDE.md
38
API_GUIDE.md
@ -711,6 +711,44 @@ For example:
|
||||
}
|
||||
```
|
||||
|
||||
### legacyPackages
|
||||
|
||||
```
|
||||
Type: Pkgs -> Pkgs
|
||||
```
|
||||
|
||||
The `legacyPackages` option allows you to configure the flake's `legacyPackges`
|
||||
output. It can be set to a function that takes the package set and returns the
|
||||
package set to be used as the corresponding system's legacyPackages output.
|
||||
|
||||
For example:
|
||||
|
||||
```nix
|
||||
{
|
||||
inputs = {
|
||||
flakelight.url = "github:nix-community/flakelight";
|
||||
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
|
||||
};
|
||||
outputs = { flakelight, nixpkgs, ... }:
|
||||
flakelight ./. {
|
||||
legacyPackages = pkgs: nixpkgs.legacyPackages.${pkgs.system};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
To export the package set used for calling package definitions and other options
|
||||
that take functions passed the package set, you can do the following:
|
||||
|
||||
```nix
|
||||
{
|
||||
inputs.flakelight.url = "github:nix-community/flakelight";
|
||||
outputs = { flakelight, ... }:
|
||||
flakelight ./. {
|
||||
legacyPackages = pkgs: pkgs;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### formatter
|
||||
|
||||
```
|
||||
|
19
builtinModules/legacyPackages.nix
Normal file
19
builtinModules/legacyPackages.nix
Normal file
@ -0,0 +1,19 @@
|
||||
# flakelight -- Framework for simplifying flake setup
|
||||
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
{ config, lib, genSystems, ... }:
|
||||
let
|
||||
inherit (lib) mkIf mkOption;
|
||||
inherit (lib.types) functionTo nullOr pkgs;
|
||||
in
|
||||
{
|
||||
options.legacyPackages = mkOption {
|
||||
type = nullOr (functionTo pkgs);
|
||||
default = null;
|
||||
};
|
||||
|
||||
config.outputs = mkIf (config.legacyPackages != null) {
|
||||
legacyPackages = genSystems config.legacyPackages;
|
||||
};
|
||||
}
|
@ -287,6 +287,22 @@ in
|
||||
})
|
||||
(f: (import f.packages.x86_64-linux.pkg2));
|
||||
|
||||
legacyPackages-set-pkgs = test
|
||||
(flakelight ./empty {
|
||||
inputs = { inherit nixpkgs; };
|
||||
legacyPackages = pkgs: pkgs;
|
||||
})
|
||||
(f: f.legacyPackages.x86_64-linux.hello
|
||||
== nixpkgs.legacyPackages.x86_64-linux.hello);
|
||||
|
||||
legacyPackages-set-nixpkgs = test
|
||||
(flakelight ./empty {
|
||||
inputs = { inherit nixpkgs; };
|
||||
legacyPackages = pkgs: nixpkgs.legacyPackages.${pkgs.system};
|
||||
})
|
||||
(f: f.legacyPackages.x86_64-linux.hello
|
||||
== nixpkgs.legacyPackages.x86_64-linux.hello);
|
||||
|
||||
devShell = test
|
||||
(flakelight ./empty {
|
||||
devShell = {
|
||||
|
Loading…
Reference in New Issue
Block a user