Skip to content

Commit

Permalink
chore(dev): add nix development shell and package
Browse files Browse the repository at this point in the history
- Updated .gitignore to include .direnv and nix package build result
- Added .envrc for nix-direnv to automatically setup development
  environment when using nix
  • Loading branch information
HeitorAugustoLN authored and Eduardo Flores committed Dec 10, 2024
1 parent 16b1e78 commit 8daac2c
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if has nix_direnv_version; then
use flake
fi
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ target/

vendor/

.cargo/
.cargo/
.direnv/
result*
98 changes: 98 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
pkgs ? import <nixpkgs> { },
...
}:
pkgs.callPackage (
{
lib,
rustPlatform,
just,
openssl,
libxkbcommon,
libGL,
xorg,
vulkan-loader,
wayland,
pkg-config,
makeWrapper,
stdenv,
cosmic-comp,
cosmic-icons,
}:
let
pname = "cosmic-ext-tweaks";
version = "0.1.3";

buildInputs = [
openssl
libGL
libxkbcommon
vulkan-loader
wayland
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
];
in
rustPlatform.buildRustPackage {
inherit pname version buildInputs;

src = builtins.path {
name = "${pname}-source";
path = ./.;
};

cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"accesskit-0.16.0" = "sha256-yeBzocXxuvHmuPGMRebbsYSKSvN+8sUsmaSKlQDpW4w=";
"atomicwrites-0.4.2" = "sha256-QZSuGPrJXh+svMeFWqAXoqZQxLq/WfIiamqvjJNVhxA=";
"clipboard_macos-0.1.0" = "sha256-tovB4fjPVVRY8LKn5albMzskFQ+1W5ul4jT5RXx9gKE=";
"cosmic-config-0.1.0" = "sha256-VVxiIJanb9gs/7sYpXtsoDdsd+QDUg0QBpBpBWVTSqo=";
"cosmic-ext-config-templates-2.0.2" = "sha256-MkccHdaB4qUOELQdWRMPyLbBM6jMg37sC+TfVHUV9Ew=";
"cosmic-panel-config-0.1.0" = "sha256-/mAffg2OuL5atwYpW64JlFsKY0s/PYR7hdPyLhhQbKQ=";
"cosmic-text-0.12.1" = "sha256-nCw3RNIHINXH4+m9wKB+0CeoXSVKKxP+ylaZhfp8u+o=";
"dpi-0.1.1" = "sha256-whi05/2vc3s5eAJTZ9TzVfGQ/EnfPr0S4PZZmbiYio0=";
"iced_glyphon-0.6.0" = "sha256-u1vnsOjP8npQ57NNSikotuHxpi4Mp/rV9038vAgCsfQ=";
"smithay-clipboard-0.8.0" = "sha256-4InFXm0ahrqFrtNLeqIuE3yeOpxKZJZx+Bc0yQDtv34=";
"softbuffer-0.4.1" = "sha256-a0bUFz6O8CWRweNt/OxTvflnPYwO5nm6vsyc/WcXyNg=";
"taffy-0.3.11" = "sha256-SCx9GEIJjWdoNVyq+RZAGn0N71qraKZxf9ZWhvyzLaI=";
};
};

nativeBuildInputs = [
just
pkg-config
makeWrapper
];

dontUseJustBuild = true;
dontUseJustCheck = true;

justFlags = [
"--set"
"prefix"
(placeholder "out")
"--set"
"bin-src"
"target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/cosmic-ext-tweaks"
];

postInstall = ''
wrapProgram $out/bin/cosmic-ext-tweaks \
--suffix XDG_DATA_DIRS : "${cosmic-icons}/share" \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
'';

meta = {
changelog = "https://github.com/cosmic-utils/tweaks/releases/tag/${version}";
description = "Tweaking tool for the COSMIC Desktop Environment";
homepage = "https://github.com/cosmic-utils/tweaks";
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [ HeitorAugustoLN ];
mainProgram = "cosmic-ext-tweaks";
inherit (cosmic-comp.meta) platforms;
};
}
) { }
69 changes: 69 additions & 0 deletions flake.lock

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

57 changes: 57 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
description = "A tweaking tool for the COSMIC desktop";

inputs = {
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs =
inputs:
let
inherit (inputs.nixpkgs) lib;
in
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"aarch64-linux"
"x86_64-linux"
];

imports = lib.optionals (inputs.treefmt-nix ? flakeModule) [ inputs.treefmt-nix.flakeModule ];

perSystem =
{ pkgs, self', ... }:
{
devShells.default = import ./shell.nix { inherit pkgs; };

packages = {
default = self'.packages.cosmic-ext-tweaks;
cosmic-ext-tweaks = import ./. { inherit pkgs; };
};
}
// lib.optionalAttrs (inputs.treefmt-nix ? flakeModule) {
treefmt.config = {
flakeCheck = true;
projectRootFile = "flake.nix";

programs = {
nixfmt = {
enable = true;
package = pkgs.nixfmt-rfc-style;
};
rustfmt = {
enable = true;
package = pkgs.rustfmt;
};
};
};
};
};
}
15 changes: 15 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
pkgs ? import <nixpkgs> { },
...
}:
pkgs.mkShell {
strictDeps = true;

nativeBuildInputs = with pkgs; [
cargo
clippy
just
rustc
rustfmt
];
}

0 comments on commit 8daac2c

Please sign in to comment.