diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d2a5c79..67e7a96 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,4 +1,4 @@ -name: Build and Upload Binary +name: Build and Upload AppImage Binary on: workflow_dispatch: diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml new file mode 100644 index 0000000..03cfd28 --- /dev/null +++ b/.github/workflows/nix.yaml @@ -0,0 +1,20 @@ +name: "Nix Build and Cache" +on: + workflow_dispatch: + inputs: + branch: + description: "main build" + required: true + default: "main" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v30 + - uses: cachix/cachix-action@v15 + with: + name: wombatfromhell + authToken: "${{ secrets.CACHIX_TOKEN }}" + - run: nix build . --print-out-paths diff --git a/.gitignore b/.gitignore index b396d97..9e27eb3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -/target -veridian-controller.toml \ No newline at end of file +target +result +veridian-controller.toml diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6c12a55 --- /dev/null +++ b/flake.lock @@ -0,0 +1,94 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1736429655, + "narHash": "sha256-BwMekRuVlSB9C0QgwKMICiJ5EVbLGjfe4qyueyNQyGI=", + "owner": "nix-community", + "repo": "naersk", + "rev": "0621e47bd95542b8e1ce2ee2d65d6a1f887a13ce", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1738297584, + "narHash": "sha256-AYvaFBzt8dU0fcSK2jKD0Vg23K2eIRxfsVXIPCW9a0E=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9189ac18287c599860e878e905da550aa6dec1cd", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1738297584, + "narHash": "sha256-AYvaFBzt8dU0fcSK2jKD0Vg23K2eIRxfsVXIPCW9a0E=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9189ac18287c599860e878e905da550aa6dec1cd", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "naersk": "naersk", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..8ae46d9 --- /dev/null +++ b/flake.nix @@ -0,0 +1,55 @@ +{ + description = "Veridian Controller"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + naersk.url = "github:nix-community/naersk"; + }; + + nixConfig = { + extra-substituters = [ + "https://wombatfromhell.cachix.org/" + ]; + extra-trusted-public-keys = [ + "wombatfromhell.cachix.org-1:pyIVJJkoLxkjH/MKK1ylrrdJKPpm+aXLeD2zAqVk9lA=" + ]; + }; + + outputs = { + self, + nixpkgs, + flake-utils, + naersk, + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs {inherit system;}; + naersk' = pkgs.callPackage naersk {}; + in { + packages = { + veridian-controller = naersk'.buildPackage { + pname = "veridian-controller"; + version = "0.2.6"; + src = ./.; + }; + default = self.packages.${system}.veridian-controller; + }; + + overlays.default = final: prev: { + veridian-controller = self.packages.${prev.system}.veridian-controller; + }; + + apps.default = flake-utils.lib.mkApp { + drv = self.packages.${system}.default; + }; + }) + // { + nixosModules.default = { + config, + pkgs, + ... + }: { + nixpkgs.overlays = [self.overlays.default]; + }; + }; +} diff --git a/unit-example.nix b/unit-example.nix new file mode 100644 index 0000000..6058c3c --- /dev/null +++ b/unit-example.nix @@ -0,0 +1,22 @@ +# include this module in your home-manager config +{ + pkgs, # make sure to include the input from your flake + ... +}: let + moduleName = "veridian-controller"; + description = "Veridian Controller User Fan Service"; +in { + # systemd user service to start the fan controller on startup + systemd.user.services."${moduleName}" = { + Unit = { + Description = "${description}"; + }; + Service = { + Type = "simple"; + ExecStart = "${pkgs.${moduleName}}/bin/${moduleName}"; + }; + Install = { + WantedBy = ["graphical-session.target"]; + }; + }; +}