Add support for configuring legacyPackages

This commit is contained in:
Archit Gupta 2024-02-05 23:10:00 -08:00
parent 086393b47b
commit 1fa95e0d84
3 changed files with 73 additions and 0 deletions

View File

@ -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
```

View 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;
};
}

View File

@ -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 = {