From 500d8a4fd46850a2e40e506d4c392533a3138d5a Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Thu, 2 Feb 2023 00:17:10 +0100 Subject: [PATCH] Add flake with home-manager --- .gitignore | 1 + README.md | 9 +++++++++ flake.lock | 53 ++++++++++++++++++++++++++++++++++++++++++++--------- flake.nix | 36 ++++++++++++++++++++++++++++++++---- home.nix | 23 +++++++++++++++++++++++ 5 files changed, 109 insertions(+), 13 deletions(-) create mode 100644 .gitignore create mode 100644 home.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..82e0cdf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/result \ No newline at end of file diff --git a/README.md b/README.md index f968ede..635df89 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,13 @@ Build and switch ```bash nixos-rebuild switch --flake .# +``` + +Build script to activate in current shell +```bash +nix build .#hmConfig..activationPackage +``` +with +```bash +./result/activate ``` \ No newline at end of file diff --git a/flake.lock b/flake.lock index e7a226e..ce3e125 100644 --- a/flake.lock +++ b/flake.lock @@ -1,25 +1,60 @@ { "nodes": { - "nixpkgs": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils" + }, "locked": { - "lastModified": 1675183161, - "narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e", + "lastModified": 1675247113, + "narHash": "sha256-+YcXjfCP4hNu8A68b/UoXFCTDwKLuLV+x/7dQnM5U/o=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "782cb855b2f23c485011a196c593e2d7e4fce746", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", + "owner": "nix-community", + "repo": "home-manager", "type": "github" } }, + "nixpkgs": { + "locked": { + "lastModified": 1675158573, + "narHash": "sha256-HkKEZA/8mt7iJ2eotjPMz6XUdjBW8E2aH0AoqLJ9vEs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e3945057be467f32028ff6b67403be08285ad8c8", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, "root": { "inputs": { + "home-manager": "home-manager", "nixpkgs": "nixpkgs" } + }, + "utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index a2f43bc..2c613d5 100644 --- a/flake.nix +++ b/flake.nix @@ -2,10 +2,14 @@ description = "A very basic flake"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + # nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager = { + url = github:nix-community/home-manager; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs }: + outputs = { self, nixpkgs, home-manager }: let system = "x86_64-linux"; pkgs = import nixpkgs { @@ -15,9 +19,33 @@ lib = nixpkgs.lib; in { nixosConfigurations = { - nixos-desktop = lib.nixosSystem { + florian = lib.nixosSystem { inherit system; - modules = [ ./configuration.nix ]; + modules = [ + ./configuration.nix + home-manager.nixosModules.home-manager { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.florian = { + imports = [ ./home.nix ]; + }; + } + ]; + }; + }; + hmConfig = { + florian = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.${system}; + modules = [ + ./home.nix + { + home = { + username = "florian"; + homeDirectory = "/home/florian"; + stateVersion = "22.11"; + }; + } + ]; }; }; }; diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..d81414c --- /dev/null +++ b/home.nix @@ -0,0 +1,23 @@ +{ config, pkgs, ... }: + +{ + # Home Manager needs a bit of information about you and the + # paths it should manage. + home.username = "florian"; + home.homeDirectory = "/home/florian"; + + # This value determines the Home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new Home Manager release introduces backwards + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + home.stateVersion = "22.11"; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + + home.packages = with pkgs; [ htop ]; +}