nixos/flake/perSystem.nix

89 lines
1.9 KiB
Nix
Raw Normal View History

{
inputs,
rootPath,
...
}: {
imports = [
(rootPath + "/treefmt.nix")
];
perSystem = {
pkgs,
system,
lib,
self',
inputs',
...
}: let
inherit (inputs) nixpkgs;
in {
_module.args.pkgs = import nixpkgs {
localSystem = {inherit system;};
config = {
allowUnfree = true;
};
overlays = [(_final: _prev: {inherit lib;})];
};
devShells.default = pkgs.mkShell {
name = "nixos-shell";
packages = with pkgs; [
nixd
nil
typos
typos-lsp
just
nvfetcher
alejandra
2025-10-22 00:59:37 +08:00
lua-language-server
];
};
legacyPackages = let
inputsScope = lib.makeScope pkgs.newScope (self: {
inherit inputs rootPath;
srcs = self.callPackage (rootPath + "/_sources/generated.nix") {};
inherit (inputs'.nixvim.legacyPackages) makeNixvim makeNixvimWithModule;
neovim_git = inputs'.neovim-nightly.packages.default;
});
in
inputsScope.overrideScope (
final: _prev:
2025-11-02 07:21:08 +08:00
lib.packagesFromDirectoryRecursive {
inherit (final) callPackage;
directory = rootPath + "/pkgs";
}
);
packages = let
flattenPkgs = path: value:
if lib.isDerivation value
then {
${lib.concatStringsSep ":" path} = value;
}
else if lib.isAttrs value
then lib.concatMapAttrs (name: flattenPkgs (path ++ [name])) value
else {};
in
flattenPkgs [] (
lib.removeAttrs self'.legacyPackages [
"inputs"
2025-11-02 07:21:08 +08:00
"srcs"
2025-11-02 07:21:08 +08:00
"rootPath"
2025-11-02 07:21:08 +08:00
"makeNixvim"
"makeNixvimWithModule"
2025-11-02 07:21:08 +08:00
"newScope"
"overrideScope"
"packages"
"callPackage"
]
);
checks =
lib.concatMapAttrs (name: value: {
"package-${name}" = value;
})
self'.packages;
};
}