Skip to content

Commit

Permalink
feat: add Nix support via home-manager module (adriankarlen#17)
Browse files Browse the repository at this point in the history
* "Upload flake, hm module and package nix files"

* Add flake.lock

* Update options property

* Install sidebery when module is enabled

* Update README to include Nix info
  • Loading branch information
shadeyg56 authored Oct 17, 2024
1 parent 83138d7 commit da0c282
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 0 deletions.
43 changes: 43 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
description = "A flake that exposes a home-manager module for textfox";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
nur.url = github:nix-community/NUR;
};

outputs = { self, nixpkgs, nur } @ inputs: let
forAllSystems = nixpkgs.lib.genAttrs ["x86_64-linux" "aarch64-linux" "x86_64-darwin"];
pkgsForEach = nixpkgs.legacyPackages;
in {
packages = forAllSystems (system: {
default = pkgsForEach.${system}.callPackage ./nix/default.nix {};
});

homeManagerModules.default = import ./nix/hm-module.nix inputs;
};
}
14 changes: 14 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{stdenv, fetchFromGithub, ...}:

stdenv.mkDerivation {
pname = "textfox";
version = "git";

src = ../.;

installPhase = ''
mkdir -p $out/chrome
cp -r chrome/* $out/chrome
cp user.js $out/user.js
'';
}
34 changes: 34 additions & 0 deletions nix/hm-module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
inputs: {config, lib, pkgs, ...}:
let
cfg = config.textfox;
inherit (pkgs.stdenv.hostPlatform) system;
package = inputs.self.packages.${system}.default;
in {

imports = [
inputs.nur.hmModules.nur
];

options.textfox = {
enable = lib.mkEnableOption "Enable textfox";
profile = lib.mkOption {
type = lib.types.str;
description = "The profile to apply the textfox configuration to";
};
};

config = lib.mkIf cfg.enable {
programs.firefox = {
enable = true;
profiles."${cfg.profile}" = {
extraConfig = builtins.readFile "${package}/user.js";
extensions = [ config.nur.repos.rycee.firefox-addons.sidebery ];
};
};

home.file.".mozilla/firefox/${cfg.profile}/chrome" = {
source = "${package}/chrome";
recursive = true;
};
};
}
88 changes: 88 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,94 @@ _a port of spotify tui to firefox_
> apply the settings in `about:config` manually. These are needed for the css to
> work.
### Nix
This repo includes a Nix flake that exposes a home-manager module that installs textfox and sidebery.

To enable the module, add the repo as a flake input, import the module, and enable textfox

If your home-manager module is defined within your `nixosConfigurations`:
```nix
# flake.nix
{
inputs = {
# ---Snip---
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
textfox.url = "github:adriankarlen/textfox";
# ---Snip---
}
outputs = {nixpkgs, home-manager, ...} @ inputs: {
nixosConfigurations.HOSTNAME = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
modules = [
home-manager.nixosModules.home-manager
{
# Must pass in inputs so we can access the module
home-manager.extraSpecialArgs = {
inherit inputs;
};
}
];
};
}
}
```
```nix
# home.nix
imports = [ inputs.textfox.homeManagerModules.default ];
textfox = {
enable = true;
profile = "firefox profile name here";
};
```


If you use `home-manager.lib.homeManagerConfiguration`
```nix
# flake.nix
inputs = {
# ---Snip---
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
textfox.url = "github:adriankarlen/textfox";
# ---Snip---
}
outputs = {nixpkgs, home-manager, textfox ...}: {
homeConfigurations."user@hostname" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
modules = [
textfox.homeManagerModules.default
# ...
];
};
};
}
```
```nix
# home.nix
textfox = {
enable = true;
profile = "firefox profile name here";
};
```

### Sidebery

Sidebery css is being set from within `content/sidebery` (applied as content to
Expand Down

0 comments on commit da0c282

Please sign in to comment.