nix-config/flake.nix

110 lines
3.9 KiB
Nix
Raw Normal View History

{
inputs = {
nixpkgs.url = "github:donovanglover/nixpkgs/unstable-hyprland-v0.41.1";
2023-05-17 05:07:14 +02:00
home-manager = {
url = "github:nix-community/home-manager";
2023-05-17 05:07:14 +02:00
inputs.nixpkgs.follows = "nixpkgs";
};
2023-05-17 05:07:14 +02:00
stylix = {
url = "github:bluskript/stylix/6bc871ab352c9f18d1179daab9e392a4d46393af";
2023-05-17 05:35:52 +02:00
inputs = {
nixpkgs.follows = "nixpkgs";
home-manager.follows = "home-manager";
};
2023-05-17 05:07:14 +02:00
};
sakaya = {
url = "github:donovanglover/sakaya";
inputs.nixpkgs.follows = "nixpkgs";
};
mobile-nixos = {
url = "github:NixOS/mobile-nixos";
flake = false;
};
2023-06-21 08:41:38 +02:00
};
outputs = { self, nixpkgs, mobile-nixos, ... } @ attrs:
let
inherit (nixpkgs.lib) nixosSystem;
inherit (nixpkgs.legacyPackages.x86_64-linux) nixpkgs-fmt callPackage;
inherit (builtins) attrNames listToAttrs map replaceStrings readDir;
flakeOutputs = [ "overlays" "nixosModules" "nixosConfigurations" "homeManagerModules" "packages" "checks" ];
flakeDirectories = [ "overlays" "modules" "hardware" "home" "packages" "tests" ];
in
{
formatter.x86_64-linux = nixpkgs-fmt;
} //
(listToAttrs
(map
(attributeName: {
name = attributeName;
value =
let
directory = replaceStrings flakeOutputs flakeDirectories attributeName;
2024-04-06 04:51:24 +02:00
attributeValue = (listToAttrs
(map
(file: {
name =
if file == "laptop.nix"
then "nixos"
else
if file == "phone.nix"
then "mobile-nixos"
else replaceStrings [ ".nix" ] [ "" ] file;
2024-04-06 04:51:24 +02:00
value =
if directory == "packages"
2024-04-06 04:51:24 +02:00
then callPackage ./${directory}/${file} { }
else
if directory == "tests"
then
import ./${directory}/${file}
{
inherit self;
pkgs = nixpkgs.legacyPackages.x86_64-linux;
}
else
if directory == "hardware"
then
nixosSystem
{
system =
if file == "phone.nix"
then "aarch64-linux"
else "x86_64-linux";
specialArgs = attrs // { nix-config = self; };
modules =
[
./${file}
./${directory}/${file}
] ++ nixpkgs.lib.optionals (file == "phone.nix") [
(import "${mobile-nixos}/lib/configuration.nix" {
device = "pine64-pinephone";
})
{
mobile.beautification = {
silentBoot = nixpkgs.lib.mkDefault true;
splash = nixpkgs.lib.mkDefault true;
};
}
];
}
else import ./${directory}/${file};
})
(attrNames (readDir ./${directory}))));
2024-04-06 04:51:24 +02:00
attributeSet =
if directory == "packages" || directory == "tests"
2024-04-06 04:51:24 +02:00
then { x86_64-linux = attributeValue; }
else attributeValue;
in
(attributeSet);
})
2024-04-01 21:29:40 +02:00
(flakeOutputs)));
}