From 24186358facc1225ec0001bc0c84d62266e759a8 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Thu, 16 Jan 2025 09:08:32 +0000 Subject: [PATCH] Add initial testfiles for home manager --- flake.lock | 48 +++++++++++++++++++++++++++++++++ flake.nix | 62 +++++++++++++++++++++++++++++++++++++++++++ nix/home.nix | 5 ++++ nix/local_machine.nix | 11 ++++++++ 4 files changed, 126 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/home.nix create mode 100644 nix/local_machine.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..70dfcf5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1736785676, + "narHash": "sha256-TY0jUwR3EW0fnS0X5wXMAVy6h4Z7Y6a3m+Yq++C9AyE=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "fc52a210b60f2f52c74eac41a8647c1573d2071d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1736883708, + "narHash": "sha256-uQ+NQ0/xYU0N1CnXsa2zghgNaOPxWpMJXSUJJ9W7140=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "eb62e6aa39ea67e0b8018ba8ea077efe65807dc8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..dfc9638 --- /dev/null +++ b/flake.nix @@ -0,0 +1,62 @@ +{ + description = "LarssonMartin1998's dotfiles configured with Home Manager"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { nixpkgs, home-manager, ... }: + let + lib = nixpkgs.lib; + + # supportedSystems = [ + # "x86_64-linux" + # "aarch64-linux" + # "aarch64-darwin" + # ]; + + makeHomeConfig = { + name, + system, + extraModules ? [] + }: + home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs { inherit system; }; + modules = [ + ./nix/home.nix + ./nix/local_machine.nix + ] + ++ extraModules + ++ lib.optional (builtins.match ".*-darwin$" system != null) ./nix/darwin.nix + ++ lib.optional (builtins.match ".*-linux$" system != null) ./nix/linux.nix; + }; + in { + homeConfigurations = { + "wsl" = makeHomeConfig { + name = "wsl"; + system = "x86_64-linux"; + extraModules = [ ./nix/wsl.nix ]; + }; + + "linux-x86" = makeHomeConfig { + name = "linux-x86"; + system = "x86_64-linux"; + }; + + "linux-aarch64" = makeHomeConfig { + name = "linux-aarch64"; + system = "aarch64-linux"; + }; + + "darwin-aarch64" = makeHomeConfig { + name = "darwin-aarch64"; + system = "aarch64-darwin"; + }; + }; + }; +} diff --git a/nix/home.nix b/nix/home.nix new file mode 100644 index 0000000..a27beb8 --- /dev/null +++ b/nix/home.nix @@ -0,0 +1,5 @@ +{ ... }: { + home = { + stateVersion = "24.05"; + }; +} diff --git a/nix/local_machine.nix b/nix/local_machine.nix new file mode 100644 index 0000000..bae0eda --- /dev/null +++ b/nix/local_machine.nix @@ -0,0 +1,11 @@ +{ ... }: { + # local-machine.nix + # This is a template file that is committed to git with minimal changes. + # In order to use this and remain pure, each machine needs to create a local branch, i.e `machine-wsl` and set these variables + # accordingly, and then commit it. + home = { + # Stub values for demonstration. Override these in local branch. + username = "nixos"; + homeDirectory = "/home/nixos"; + }; +}