Skip to content

Commit

Permalink
nix: use flake
Browse files Browse the repository at this point in the history
  • Loading branch information
DashieTM committed May 20, 2024
1 parent d9b17e6 commit b11001a
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
use nix
use flake
48 changes: 48 additions & 0 deletions flake.lock

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

50 changes: 50 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
description = "A work in progress notification daemon made with rust and gtk.";

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

outputs = inputs @ { flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" ];

perSystem =
{ config
, self'
, inputs'
, pkgs
, system
, ...
}:
{
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues self'.packages;
packages = with pkgs; [
cargo
rustc
];
};

packages =
let
lockFile = ./Cargo.lock;
in
rec {
oxinoti = pkgs.callPackage ./nix/default.nix { inherit inputs lockFile; };
default = oxinoti;
};
};
flake = _: rec {
nixosModules.home-manager = homeManagerModules.default;
homeManagerModules = rec {
oxinoti = import ./nix/hm.nix inputs.self;
default = oxinoti;
};
};
};
}
51 changes: 51 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{ rustPlatform
, pkg-config
, wrapGAppsHook4
, gtk3
, gtk-layer-shell
, dbus
, lib
, lockFile
, cargo
, rustc
, ...
}:
let
cargoToml = builtins.fromTOML (builtins.readFile ../Cargo.toml);
in
rustPlatform.buildRustPackage rec {
pname = cargoToml.package.name;
version = cargoToml.package.version;

src = ../.;

buildInputs = [
pkg-config
gtk3
gtk-layer-shell
dbus
];

cargoLock = {
inherit lockFile;
};

checkInputs = [ cargo rustc ];

nativeBuildInputs = [
pkg-config
wrapGAppsHook4
cargo
rustc
];
copyLibs = true;

meta = with lib; {
description = "A small, simple calculator written in rust/gtk4";
homepage = "https://github.com/DashieTM/OxiNoti";
changelog = "https://github.com/DashieTM/OxiNoti/releases/tag/${version}";
license = licenses.gpl3;
maintainers = with maintainers; [ DashieTM ];
mainProgram = "oxinoti";
};
}
30 changes: 30 additions & 0 deletions nix/hm.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
self: { config
, pkgs
, lib
, hm
, ...
}:
let
cfg = config.programs.oxinoti;
defaultPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
in
{
meta.maintainers = with lib.maintainers; [ DashieTM ];
options.programs.oxinoti = with lib; {
enable = mkEnableOption "oxinoti";

package = mkOption {
type = with types; nullOr package;
default = defaultPackage;
defaultText = lib.literalExpression ''
oxinoti.packages.''${pkgs.stdenv.hostPlatform.system}.default
'';
description = mdDoc ''
Package to run
'';
};
};
config = lib.mkIf cfg.enable {
home.packages = lib.optional (cfg.package != null) cfg.package;
};
}
15 changes: 0 additions & 15 deletions shell.nix

This file was deleted.

0 comments on commit b11001a

Please sign in to comment.