2021-11-25 11:55:30 +00:00
|
|
|
{
|
|
|
|
description = "foo-dogsquared's NixOS config as a flake";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
|
|
|
|
home-manager.url = "github:nix-community/home-manager";
|
|
|
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
|
|
|
agenix.url = "github:ryantm/agenix";
|
|
|
|
agenix.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
2021-11-29 05:30:57 +00:00
|
|
|
outputs = inputs@{ self, nixpkgs, home-manager, ... }:
|
2021-11-25 11:55:30 +00:00
|
|
|
let
|
2021-11-29 09:56:24 +00:00
|
|
|
# All the target systems.
|
|
|
|
systems = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"i686-linux"
|
|
|
|
"aarch64-linux"
|
|
|
|
"armv6l-linux"
|
|
|
|
"armv7l-linux"
|
|
|
|
];
|
|
|
|
|
|
|
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
|
|
|
|
libExtended = nixpkgs.lib.extend (final: prev:
|
|
|
|
(import ./lib {
|
|
|
|
inherit inputs;
|
|
|
|
lib = final;
|
|
|
|
}));
|
2021-11-25 11:55:30 +00:00
|
|
|
|
|
|
|
hostDefaultConfig = {
|
|
|
|
# Stallman-senpai will be disappointed.
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
2021-11-29 09:56:24 +00:00
|
|
|
|
2021-12-02 13:48:44 +00:00
|
|
|
# Extend nixpkgs with our own package set.
|
|
|
|
nixpkgs.overlays = [ (self: super: import ./pkgs { pkgs = super; }) ];
|
|
|
|
|
2021-11-25 11:55:30 +00:00
|
|
|
# We live in a Unicode world and dominantly English in technical fields so we'll
|
|
|
|
# have to go with it.
|
|
|
|
i18n.defaultLocale = "en_US.UTF-8";
|
2021-11-29 09:56:24 +00:00
|
|
|
|
2021-11-25 11:55:30 +00:00
|
|
|
# Sane config for the package manager.
|
|
|
|
nix.gc = {
|
|
|
|
automatic = true;
|
|
|
|
dates = "monthly";
|
|
|
|
options = "--delete-older-than 2w";
|
|
|
|
};
|
2021-11-29 09:56:24 +00:00
|
|
|
|
2021-11-25 11:55:30 +00:00
|
|
|
# TODO: Remove this after nix-command and flakes has been considered stable.
|
2021-11-29 05:30:57 +00:00
|
|
|
#
|
|
|
|
# Since we're using flakes to make this possible, we need it.
|
|
|
|
# Plus, the UX of Nix CLI is becoming closer to Guix's which is a nice bonus.
|
2021-11-25 11:55:30 +00:00
|
|
|
nix.extraOptions = ''
|
|
|
|
experimental-features = nix-command flakes
|
|
|
|
'';
|
|
|
|
};
|
2021-11-29 05:30:57 +00:00
|
|
|
|
2021-11-29 09:56:24 +00:00
|
|
|
userDefaultConfig = { system = "x86_64-linux"; };
|
2021-11-25 11:55:30 +00:00
|
|
|
in {
|
2021-11-27 08:04:01 +00:00
|
|
|
# Exposes only my library with the custom functions to make it easier to include in other flakes.
|
2021-11-29 09:56:24 +00:00
|
|
|
lib = import ./lib {
|
|
|
|
inherit inputs;
|
|
|
|
lib = nixpkgs.lib;
|
|
|
|
};
|
2021-11-25 11:55:30 +00:00
|
|
|
|
|
|
|
# A list of NixOS configurations from the `./hosts` folder.
|
|
|
|
# It also has some sensible default configurations.
|
2021-11-29 09:56:24 +00:00
|
|
|
nixosConfigurations = libExtended.mapAttrs
|
|
|
|
(host: path: libExtended.mkHost path hostDefaultConfig)
|
|
|
|
(libExtended.filesToAttr ./hosts);
|
2021-11-25 11:55:30 +00:00
|
|
|
|
|
|
|
# We're going to make our custom modules available for our flake. Whether
|
|
|
|
# or not this is a good thing is debatable, I just want to test it.
|
2021-12-02 13:48:44 +00:00
|
|
|
nixosModules = libExtended.mapAttrsRecursive (_: path: import path)
|
2021-11-29 09:56:24 +00:00
|
|
|
(libExtended.filesToAttr ./modules);
|
|
|
|
|
|
|
|
homeConfigurations = let
|
|
|
|
excludedModules = [
|
|
|
|
"config" # The common user-specific configurations.
|
|
|
|
"modules" # User-specific Nix modules.
|
|
|
|
];
|
|
|
|
in libExtended.mapAttrs (user: path:
|
|
|
|
home-manager.lib.homeManagerConfiguration {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
configuration = import path;
|
|
|
|
homeDirectory = "/home/${user}";
|
|
|
|
username = user;
|
|
|
|
}) (libExtended.filterAttrs (n: v: !libExtended.elem n excludedModules)
|
|
|
|
(libExtended.filesToAttr ./users));
|
2021-11-29 05:30:57 +00:00
|
|
|
|
2021-11-29 09:58:02 +00:00
|
|
|
packages = forAllSystems
|
|
|
|
(system: import ./pkgs { pkgs = import nixpkgs { inherit system; }; });
|
2021-11-25 11:55:30 +00:00
|
|
|
};
|
|
|
|
}
|