From 0caff84048fdc4d25a7b76329a9762e019325d38 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 4 Feb 2024 02:10:17 +0300 Subject: [PATCH] initial commit --- .envrc | 1 + flake.lock | 64 ++++++++++++++++++++++++++++++++++++++++ flake.nix | 27 +++++++++++++++++ hosts/caesar/default.nix | 1 + hosts/default.nix | 29 ++++++++++++++++++ 5 files changed, 122 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hosts/caesar/default.nix create mode 100644 hosts/default.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8cfc782 --- /dev/null +++ b/flake.lock @@ -0,0 +1,64 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1706830856, + "narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1706732774, + "narHash": "sha256-hqJlyJk4MRpcItGYMF+3uHe8HvxNETWvlGtLuVpqLU0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b8b232ae7b8b144397fdb12d20f592e5e7c1a64d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1706550542, + "narHash": "sha256-UcsnCG6wx++23yeER4Hg18CXWbgNpqNXcHIo5/1Y+hc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "97b17f32362e475016f942bbdfda4a4a72a8a652", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..18778ac --- /dev/null +++ b/flake.nix @@ -0,0 +1,27 @@ +{ + description = "Hyprland Infrastructure"; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = { + self, + flake-parts, + ... + } @ inputs: + flake-parts.lib.mkFlake {inherit inputs;} { + systems = ["x86_64-linux"]; + + perSystem = {pkgs, ...}: { + devShells.default = pkgs.mkShell { + buildInputs = [pkgs.alejandra]; + }; + }; + + flake = { + nixosConfigurations = import ./hosts {inherit self;}; + }; + }; +} diff --git a/hosts/caesar/default.nix b/hosts/caesar/default.nix new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/hosts/caesar/default.nix @@ -0,0 +1 @@ +{} diff --git a/hosts/default.nix b/hosts/default.nix new file mode 100644 index 0000000..95c79d8 --- /dev/null +++ b/hosts/default.nix @@ -0,0 +1,29 @@ +{self, ...}: let + inherit (self) inputs; + + # TODO: move to standalone lib directory + mkSystem = inputs.nixpkgs.lib.nixosSystem; + + # mkNixosSystem wraps mkSystem (a.k.a lib.nixosSystem) with flake-parts' withSystem to provide inputs' and self' from flake-parts + # it also acts as a template for my nixos hosts with system type and modules being imported beforehand + # specialArgs is also defined here to avoid defining them for each host and lazily merged if the host defines any other args + mkNixosSystem = { + modules, + system, + hostname, + ... + } @ args: + mkSystem { + inherit system; + modules = {networking.hostName = hostname;} // args.modules or {}; + specialArgs = {inherit inputs self;} // args.specialArgs or {}; + }; +in { + "caesar" = mkNixosSystem { + hostname = "caesar"; + system = "x86_64-linux"; + modules = [ + ./caesar + ]; + }; +}