Created
September 19, 2022 18:02
-
-
Save m0ar/e55d64377df5ae02e68af75159dd1292 to your computer and use it in GitHub Desktop.
Basic flake for a `home-manager` setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
description = "Home-manager configuration"; | |
inputs = { | |
utils.url = "github:numtide/flake-utils"; | |
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; | |
home-manager = { | |
url = "github:nix-community/home-manager"; | |
inputs.nixpkgs.follows = "nixpkgs"; | |
}; | |
nixgl.url = "github:guibou/nixGL"; | |
}; | |
outputs = { self, home-manager, nixgl, nixpkgs, utils }: | |
let | |
system = "x86_64-linux"; | |
pkgs = import nixpkgs { | |
inherit system; | |
overlays = [ nixgl.overlay ]; | |
}; | |
in { | |
homeConfigurations.laptop = home-manager.lib.homeManagerConfiguration { | |
inherit pkgs; | |
modules = [ ./home.nix ]; | |
}; | |
# Workaround from https://github.com/nix-community/home-manager/issues/2848#issuecomment-1196005666 | |
laptop = self.homeConfigurations.laptop.activationPackage; | |
apps.x86_64-linux.update-home = | |
let nix = nixpkgs.legacyPackages.x86_64-linux.nix; | |
in { | |
type = "app"; | |
program = | |
(nixpkgs.legacyPackages.x86_64-linux.writeScript "update-home" '' | |
set -euo pipefail | |
old_profile=$(${nix}/bin/nix profile list | grep home-manager-path | head -n1 | awk '{print $4}') | |
echo $old_profile | |
${nix}/bin/nix profile remove $old_profile | |
${self.laptop}/activate || (echo "restoring old profile"; ${nix}/bin/nix profile install $old_profile) | |
'').outPath; | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment