Skip to content

Commit

Permalink
Adding homeManager-module (#33)
Browse files Browse the repository at this point in the history
* adding home-manager module
* adding README instruction for home-manager-module
* home-manager: add example config
  • Loading branch information
TornaxO7 authored Jun 12, 2024
1 parent 5181674 commit 14c8ccd
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 3 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,55 @@ For example:

</details>

##### Home-Manager
There's a home-manager module which adds `programs.bugstalker` to your home-manager config.
You can add it by doing the following:

<details>

```nix
{
description = "NixOS configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
bugstalker.url = "github:godzie44/BugStalker";
};
outputs = inputs@{ nixpkgs, home-manager, bugstalker, ... }: {
nixosConfigurations = {
hostname = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.sharedModules = [
bugstalker.homeManagerModules.default
({...}: {
programs.bugstalker = {
enable = true;
# the content of `keymap.toml`
keymap = {
common = {
up = ["k"];
}
};
};
})
];
}
];
};
};
};
}
```

</details>

---

## Start debugger session
Expand Down
16 changes: 13 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
flake-parts.url = "github:hercules-ci/flake-parts";
};

outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; }
outputs = inputs@{ self, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit self inputs; }
{
systems = [
"x86_64-linux"
Expand All @@ -27,7 +27,10 @@
program = self'.packages.default;
};

packages.default = pkgs.callPackage (import ./nix/package.nix) { };
packages = rec {
default = bugstalker;
bugstalker = pkgs.callPackage (import ./nix/package.nix) { };
};

devShells.default =
let
Expand All @@ -38,5 +41,12 @@
packages = [ rust-toolchain ] ++ bs.buildInputs ++ bs.nativeBuildInputs;
};
};

flake = {
homeManagerModules = rec {
default = bugstalker;
bugstalker = import ./nix/home-manager-module.nix self;
};
};
};
}
31 changes: 31 additions & 0 deletions nix/home-manager-module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
self: { config, lib, pkgs, ... }:
with lib;
let
bugstalker = self.packages.${pkgs.stdenv.hostPlatform.system}.bugstalker;
pkgs_with_bugstalker = pkgs // { inherit bugstalker; };

cfg = config.programs.bugstalker;
tomlFormat = pkgs.formats.toml { };
in
{
options.programs.bugstalker = {
enable = mkEnableOption "Bugstalker";

package = mkPackageOption pkgs_with_bugstalker "Bugstalker" {
default = [ bugstalker.pname ];
};

keymap = mkOption {
type = tomlFormat.type;
default = { };
};
};

config = mkIf cfg.enable {
home.packages = [ cfg.package ];

xdg.configFile."bs/keymap.toml" = lib.mkIf (cfg.keymap != { }) {
source = (tomlFormat.generate "keymap.toml" cfg.keymap);
};
};
}

0 comments on commit 14c8ccd

Please sign in to comment.