nixos/flake.nix

134 lines
4.5 KiB
Nix

# _
# _ __ (_)_ _____ ___
# | '_ \| \ \/ / _ \/ __|
# | | | | |> < (_) \__ \
# |_| |_|_/_/\_\___/|___/
# this configuration file is copied/inspired from https://github.com/chfour/nixos
# with lots of examples and knowledge gained with the standard config from https://github.com/Misterio77/nix-starter-configs
# and also this wonderful book https://nixos-and-flakes.thiscute.world
# shoutouts to yall 🙏
{
description = "Sneexy's custom nixos configs";
inputs = {
# nixpkgs from the unstable branch. since stable is a bit too dated
# for my personal taste
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# "fresh from git" master branch of nixpkgs. for packages not yet in unstable
nixpkgs-master.url = "github:NixOS/nixpkgs/master";
# chaotic's team nyx repo which usually contains unstable git packages or custom
# packages, such as modified linux kernels (which we do use here)
chaotic.url = "github:chaotic-cx/nyx/nyxpkgs-unstable";
# home manager for managing user specific stuff
home-manager = {
url = "github:nix-community/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
};
# plasma manager to allow configuring plasma within nix config
plasma-manager = {
url = "github:pjones/plasma-manager";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
};
# flake for 06cb:009a fingerprint scanners. to make the fingerprint scanner on my
# thinkpad t480 function.
nixos-06cb-009a-fingerprint-sensor = {
url = "github:ahbnr/nixos-06cb-009a-fingerprint-sensor";
inputs.nixpkgs.follows = "nixpkgs";
};
# hardware flakes for some devices
hardware.url = "github:nixos/nixos-hardware";
};
outputs = {
self,
nixpkgs,
nixpkgs-master,
chaotic,
home-manager,
plasma-manager,
nixos-06cb-009a-fingerprint-sensor,
hardware,
...
} @ inputs: let
inherit (self) outputs;
# our systems are all x86_64 unfortunately
systems = [
"x86_64-linux"
];
# This is a function that generates an attribute by calling a function you
# pass to it, with each system as an argument
forAllSystems = nixpkgs.lib.genAttrs systems;
in {
# setup modules and stuff idk whats going on here
nixosModules = {
declarativeHome = { ... }: {
imports = [ home-manager.nixosModules.home-manager ];
config = {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
};
};
defaults = { ... }: {
nixpkgs.config.allowUnfree = true;
nix.settings = {
experimental-features = [ "nix-command" "flakes" ];
auto-optimise-store = true;
};
environment.stub-ld.enable = false; # 24.05
};
};
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#your-hostname'
nixosConfigurations = {
# main laptop i use daily
"thunkpad" = nixpkgs.lib.nixosSystem rec {
specialArgs = {inherit inputs outputs;};
modules = with self.nixosModules; [
# nixos configuration file (and others) for thunkpad
./machines/thunkpad
# fingerprint modules
nixos-06cb-009a-fingerprint-sensor.nixosModules.open-fprintd
nixos-06cb-009a-fingerprint-sensor.nixosModules.python-validity
];
};
# secondary 2 in 1 device, not really used
"thonkpad" = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = with self.nixosModules; [
# nixos configuration file (and others) for thonkpad
./machines/thonkpad
];
};
};
# Standalone home-manager configuration entrypoint
# Available through 'home-manager --flake .#your-username@your-hostname'
homeConfigurations = {
# TODO: theres probably a better way to do this/specify one home config for all devices
# main device
"thunkpad" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = {inherit inputs outputs;};
modules = [
./machines/thunkpad
];
};
# secondary device
"thonkpad" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = {inherit inputs outputs;};
modules = [
./machines/thonkpad
];
};
};
};
}