❄ Personal NixOS Flake Manager
nixos
home-manager
go
nix
1{
2 description = "Personal NixOS Flake Manager";
3
4 inputs = {
5 nixpkgs.url = "github:NixOS/nixpkgs";
6 systems.url = "github:nix-systems/default";
7
8 flake-compat = {
9 url = "github:edolstra/flake-compat";
10 flake = false;
11 };
12
13 flake-utils = {
14 url = "github:numtide/flake-utils";
15 inputs.systems.follows = "systems";
16 };
17
18 pre-commit-hooks = {
19 url = "github:cachix/git-hooks.nix";
20
21 inputs = {
22 flake-compat.follows = "flake-compat";
23 nixpkgs.follows = "nixpkgs";
24 };
25 };
26 };
27
28 outputs =
29 {
30 self,
31 nixpkgs,
32 flake-utils,
33 pre-commit-hooks,
34 ...
35 }:
36 flake-utils.lib.eachDefaultSystem (
37 system:
38 let
39 pkgs = import nixpkgs { inherit system; };
40
41 meta = with pkgs.lib; {
42 description = "Personal NixOS Flake Manager";
43 homepage = "https://github.com/Fuwn/rui";
44 license = licenses.gpl3Only;
45 maintainers = [ maintainers.Fuwn ];
46 mainPackage = "rui";
47 platforms = platforms.linux;
48 };
49
50 rui =
51 pkgs.buildGo123Module.override { stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.clangStdenv; }
52 rec {
53 inherit meta;
54
55 pname = "rui";
56 version = "2024.10.12";
57 src = pkgs.lib.cleanSource ./.;
58 vendorHash = "sha256-mN/QjzJ4eGfbW1H92cCKvC0wDhCR6IUes2HCZ5YBdPA=";
59 buildInputs = [ pkgs.musl ];
60
61 ldflags = [
62 "-s"
63 "-w"
64 "-linkmode=external"
65 "-extldflags=-static"
66 "-X main.Version=${version}"
67 "-X main.Commit=${version}"
68 ];
69 };
70 in
71 {
72 packages = {
73 default = rui;
74 rui = self.packages.${system}.default;
75 };
76
77 apps = {
78 default = {
79 inherit meta;
80
81 type = "app";
82 program = "${self.packages.${system}.default}/bin/rui";
83 };
84
85 rui = self.apps.${system}.default;
86 };
87
88 formatter = nixpkgs.legacyPackages."${system}".nixfmt-rfc-style;
89
90 checks.pre-commit-check = pre-commit-hooks.lib.${system}.run {
91 src = ./.;
92
93 hooks = {
94 deadnix.enable = true;
95 flake-checker.enable = true;
96 nixfmt-rfc-style.enable = true;
97 statix.enable = true;
98 };
99 };
100
101 devShells.default = nixpkgs.legacyPackages.${system}.mkShell {
102 inherit (self.checks.${system}.pre-commit-check) shellHook;
103
104 buildInputs = self.checks.${system}.pre-commit-check.enabledPackages ++ [
105 pkgs.go_1_22
106 ];
107 };
108
109 homeManagerModules.default =
110 { config, ... }:
111 with pkgs.lib;
112 {
113 options.programs.rui = {
114 enable = mkOption {
115 type = types.bool;
116 default = false;
117 };
118
119 settings = {
120 editor = mkOption {
121 type = types.str;
122 default = "";
123 };
124
125 notify = mkOption {
126 type = types.bool;
127 default = false;
128 };
129
130 notifier = mkOption {
131 type = types.str;
132 default = "notify-send";
133 };
134
135 flake = mkOption {
136 type = types.str;
137 default = "";
138 };
139
140 allow-unfree = mkOption {
141 type = types.bool;
142 default = false;
143 };
144
145 extra-args = mkOption {
146 type = types.listOf types.str;
147 default = [ ];
148 };
149 };
150 };
151
152 config = mkIf config.programs.rui.enable {
153 home.packages = [
154 self.packages.${system}.default
155 pkgs.libnotify
156 ];
157
158 xdg.configFile."rui/config.json".text = builtins.toJSON config.programs.rui.settings;
159 };
160 };
161 }
162 );
163}