Upstreamed flake-module.nix to nixos-flake

https://github.com/srid/nixos-flake/pull/74
This commit is contained in:
Sridhar Ratnakumar 2024-09-30 20:14:07 -04:00
parent 56c93e3a96
commit 19b0fe2e8f
No known key found for this signature in database
4 changed files with 9 additions and 62 deletions

View file

@ -1,52 +0,0 @@
# An opinionated module that creates flake outputs based on a known directory structure.
#
# cf. Convention over configuration
#
# TODO: Upstream this in some fashion. To srid/nixos-flake?
# cf. https://github.com/juspay/nix-dev-home/issues/86
{ inputs, self, ... }:
let
inherit (inputs.nixpkgs) lib;
forAllNixFiles = dir: f:
lib.pipe dir [
builtins.readDir
(lib.filterAttrs (_: type: type == "regular"))
(lib.mapAttrs' (fn: _:
let name = lib.removeSuffix ".nix" fn; in
lib.nameValuePair name (f "${dir}/${fn}")
))
];
in
{
flake = {
darwinConfigurations =
forAllNixFiles "${self}/configurations/darwin"
(fn: self.nixos-flake.lib.mkMacosSystem { home-manager = true; } fn);
nixosConfigurations =
forAllNixFiles "${self}/configurations/nixos"
(fn: self.nixos-flake.lib.mkLinuxSystem { home-manager = true; } fn);
darwinModules =
forAllNixFiles "${self}/modules/darwin"
(fn: fn);
nixosModules =
forAllNixFiles "${self}/modules/nixos"
(fn: fn);
homeModules =
forAllNixFiles "${self}/modules/home"
(fn: fn);
overlays =
forAllNixFiles "${self}/overlays"
(fn: import fn self.nixos-flake.lib.specialArgsFor.common);
};
perSystem = { pkgs, ... }: {
legacyPackages.homeConfigurations =
forAllNixFiles "${self}/configurations/home"
(fn: self.nixos-flake.lib.mkHomeConfiguration pkgs fn);
};
}

7
flake.lock generated
View file

@ -691,15 +691,16 @@
},
"nixos-flake": {
"locked": {
"lastModified": 1727477509,
"narHash": "sha256-XJ9uyX56tEj5ketnpaGRJ25RLUctDReh44tRySh2yEA=",
"lastModified": 1727741402,
"narHash": "sha256-dUtUaG8norNNdqX9UM/31/fbpkiyBf4iKLr02agjEcI=",
"owner": "srid",
"repo": "nixos-flake",
"rev": "f76d630f1d3a271ae9af118b54e9493d231236ea",
"rev": "82752b478b4ae17248983a4cbc6a7dbd0acb71a1",
"type": "github"
},
"original": {
"owner": "srid",
"ref": "autoWire",
"repo": "nixos-flake",
"type": "github"
}

View file

@ -10,7 +10,7 @@
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
nixos-hardware.url = "github:NixOS/nixos-hardware";
nixos-flake.url = "github:srid/nixos-flake";
nixos-flake.url = "github:srid/nixos-flake/autoWire"; # https://github.com/srid/nixos-flake/pull/74
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";
ragenix.url = "github:yaxitech/ragenix";
@ -39,12 +39,9 @@
imports = (with builtins;
map
(fn: ./modules/flake-parts/${fn})
(attrNames (readDir ./modules/flake-parts))) ++
[
./flake-module.nix
];
(attrNames (readDir ./modules/flake-parts)));
perSystem = { self', pkgs, lib, system, ... }: {
perSystem = { lib, system, ... }: {
# Make our overlay available to the devShell
# "Flake parts does not yet come with an endorsed module that initializes the pkgs argument.""
# So we must do this manually; https://flake.parts/overlays#consuming-an-overlay

View file

@ -1,7 +1,8 @@
{ inputs, ... }:
{
imports = [
inputs.nixos-flake.flakeModule
inputs.nixos-flake.flakeModules.default
inputs.nixos-flake.flakeModules.autoWire
];
perSystem = { self', ... }: {
packages.default = self'.packages.activate;