mirror of
https://github.com/msfjarvis/clipboard-substitutor
synced 2025-08-14 20:07:01 +05:30
feat(nix): migrate to Nix Flakes
Fixes SDP-28
This commit is contained in:
parent
ffbc5af2d9
commit
341a85ad5c
6 changed files with 241 additions and 53 deletions
7
.github/workflows/test.yml
vendored
7
.github/workflows/test.yml
vendored
|
@ -10,6 +10,7 @@ on:
|
|||
name: Check Rust code
|
||||
jobs:
|
||||
check:
|
||||
uses: msfjarvis/shared-workflows/.github/workflows/test-rust-project.yml@main
|
||||
with:
|
||||
apt_packages: libxcb-xfixes0-dev libxcb-shape0-dev
|
||||
uses: msfjarvis/shared-workflows/.github/workflows/test-flakes-project.yml@main
|
||||
secrets:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
cachix-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
|
||||
|
|
6
default.nix
Normal file
6
default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
(import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
in fetchTarball {
|
||||
url =
|
||||
"https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||
}) { src = ./.; }).defaultNix
|
131
flake.lock
generated
Normal file
131
flake.lock
generated
Normal file
|
@ -0,0 +1,131 @@
|
|||
{
|
||||
"nodes": {
|
||||
"advisory-db": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1669556130,
|
||||
"narHash": "sha256-6qRQVSgpw+Tw17TroiUg8nAte9/KVDH+v30MOOd+pQU=",
|
||||
"owner": "rustsec",
|
||||
"repo": "advisory-db",
|
||||
"rev": "a66a3049c98395410a2afadf0382882b0a04d8b1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "rustsec",
|
||||
"repo": "advisory-db",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"crane": {
|
||||
"inputs": {
|
||||
"flake-compat": [
|
||||
"flake-compat"
|
||||
],
|
||||
"flake-utils": [
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"rust-overlay": [
|
||||
"rust-overlay"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1669605882,
|
||||
"narHash": "sha256-TiQtL5sUI5rp28S63v+VX25qNjcrc8Xeu+shf3g7Tj4=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "24591d5f8cc979f7b243b88a2d39da09976970ad",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1668681692,
|
||||
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "009399224d5e398d03b22badca40a37ac85412a1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1669597967,
|
||||
"narHash": "sha256-R+2NaDkXsYkOpFOhmVR8jBZ77Pq55Z6ilaqwFLLn000=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "be9e3762e719211368d186f547f847737baad720",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"advisory-db": "advisory-db",
|
||||
"crane": "crane",
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1669689198,
|
||||
"narHash": "sha256-YsWu3C9IGbH3+xguTzEDyQorFe/igr6FGZ+Q5T2ocxE=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "4e093ce661a63aca4bcbace33695225eae4ef4e4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
94
flake.nix
Normal file
94
flake.nix
Normal file
|
@ -0,0 +1,94 @@
|
|||
{
|
||||
description = "clipboard-substitutor";
|
||||
|
||||
inputs = {
|
||||
nixpkgs = { url = "github:NixOS/nixpkgs/nixpkgs-unstable"; };
|
||||
|
||||
flake-utils = { url = "github:numtide/flake-utils"; };
|
||||
|
||||
flake-compat = {
|
||||
url = "github:edolstra/flake-compat";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs = {
|
||||
nixpkgs.follows = "nixpkgs";
|
||||
flake-utils.follows = "flake-utils";
|
||||
};
|
||||
};
|
||||
|
||||
crane = {
|
||||
url = "github:ipetkov/crane";
|
||||
inputs = {
|
||||
flake-compat.follows = "flake-compat";
|
||||
flake-utils.follows = "flake-utils";
|
||||
nixpkgs.follows = "nixpkgs";
|
||||
rust-overlay.follows = "rust-overlay";
|
||||
};
|
||||
};
|
||||
|
||||
advisory-db = {
|
||||
url = "github:rustsec/advisory-db";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ self, nixpkgs, crane, flake-utils, advisory-db, rust-overlay, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ (import rust-overlay) ];
|
||||
};
|
||||
|
||||
rustStable =
|
||||
pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain rustStable;
|
||||
src = ./.;
|
||||
buildInputs = with pkgs;
|
||||
[ xorg.libxcb python39 ] ++ pkgs.lib.optionals stdenv.isDarwin
|
||||
[ pkgs.darwin.apple_sdk.frameworks.AppKit ];
|
||||
cargoArtifacts = craneLib.buildDepsOnly { inherit src buildInputs; };
|
||||
|
||||
clipboard-substitutor = craneLib.buildPackage {
|
||||
inherit src buildInputs;
|
||||
doCheck = false;
|
||||
};
|
||||
clipboard-substitutor-clippy = craneLib.cargoClippy {
|
||||
inherit cargoArtifacts src buildInputs;
|
||||
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
||||
};
|
||||
clipboard-substitutor-fmt = craneLib.cargoFmt { inherit src; };
|
||||
clipboard-substitutor-audit =
|
||||
craneLib.cargoAudit { inherit src advisory-db; };
|
||||
clipboard-substitutor-nextest = craneLib.cargoNextest {
|
||||
inherit cargoArtifacts src buildInputs;
|
||||
partitions = 1;
|
||||
partitionType = "count";
|
||||
};
|
||||
in {
|
||||
checks = {
|
||||
# TODO: migrate to cargo-audit
|
||||
# clipboard-substitutor-audit
|
||||
inherit clipboard-substitutor clipboard-substitutor-clippy
|
||||
clipboard-substitutor-fmt clipboard-substitutor-nextest;
|
||||
};
|
||||
|
||||
packages.default = clipboard-substitutor;
|
||||
|
||||
apps.default = flake-utils.lib.mkApp { drv = clipboard-substitutor; };
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
inputsFrom = builtins.attrValues self.checks;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
cargo-nextest
|
||||
cargo-release
|
||||
rustStable
|
||||
];
|
||||
};
|
||||
});
|
||||
}
|
42
justfile
42
justfile
|
@ -1,42 +0,0 @@
|
|||
alias b := build
|
||||
alias c := check
|
||||
alias cl := clippy
|
||||
alias f := fmt
|
||||
alias r := run
|
||||
alias t := test
|
||||
|
||||
set positional-arguments := true
|
||||
set dotenv-load := true
|
||||
|
||||
_default:
|
||||
just --list
|
||||
|
||||
build *args:
|
||||
cargo build {{ args }}
|
||||
|
||||
check *args:
|
||||
cargo check {{ args }}
|
||||
|
||||
clippy *args:
|
||||
cargo clippy {{ args }}
|
||||
|
||||
fmt:
|
||||
cargo fmt
|
||||
|
||||
log:
|
||||
journalctl --user -xeu clipboard-substitutor.service
|
||||
|
||||
run type="":
|
||||
cargo run {{ type }}
|
||||
|
||||
start:
|
||||
systemctl --user start clipboard-substitutor.service
|
||||
|
||||
status:
|
||||
systemctl --user status clipboard-substitutor.service
|
||||
|
||||
stop:
|
||||
systemctl --user stop clipboard-substitutor.service
|
||||
|
||||
test *args:
|
||||
cargo nextest run {{ args }}
|
14
shell.nix
14
shell.nix
|
@ -1,8 +1,6 @@
|
|||
{ pkgs ? import <nixpkgs> { } }:
|
||||
pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
xorg.libxcb
|
||||
python39
|
||||
] ++ pkgs.lib.optionals stdenv.isDarwin
|
||||
[ pkgs.darwin.apple_sdk.frameworks.AppKit ];
|
||||
}
|
||||
(import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
in fetchTarball {
|
||||
url =
|
||||
"https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||
}) { src = ./.; }).shellNix
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue