Skip to content

Commit

Permalink
Merge pull request #20 from javalsai/nix-flake
Browse files Browse the repository at this point in the history
feat: add Nix flake
  • Loading branch information
javalsai authored Aug 27, 2024
2 parents 154308d + 8bdfa7d commit e3052ec
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ dist/
/compile_commands.json

.cache/

# nix build result
result
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ LDIR=lib
IDIR=include
ODIR=dist

CC=gcc
PREFIX=/usr

CC?=gcc
CFLAGS?=-O3
_CFLAGS=-I$(DIR)
ALLFLAGS=$(CFLAGS) -I$(IDIR)
Expand All @@ -27,13 +29,14 @@ lidm: $(OBJ)
clean:
rm -f $(ODIR)/*.o *- li $(INCDIR)/*-

# Copy lidm to /usr/bin
# Copy lidm to ${DESTDIR}${PREFIX}/bin (/usr/bin)
install: lidm
install -m755 ./lidm /usr/bin
install -m755 ./themes/default.ini /etc/lidm.ini
mkdir -p ${DESTDIR}${PREFIX}/bin ${DESTDIR}/etc
install -m755 ./lidm ${DESTDIR}${PREFIX}/bin
install -m755 ./themes/default.ini ${DESTDIR}/etc/lidm.ini

uninstall:
rm -rf /usr/bin/lidm /etc/lidm.ini
rm -rf ${DESTDIR}${PREFIX}/bin/lidm ${DESTDIR}/etc/lidm.ini

install-service:
@if command -v systemctl &> /dev/null; then \
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

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

46 changes: 46 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs =
{ flake-utils, nixpkgs, ... }:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };

name = "LiDM";
version = "0.0.1";

lidm = (
pkgs.stdenv.mkDerivation {
pname = name;
version = version;

src = ./.;

nativeBuildInputs = with pkgs; [
gcc
gnumake
linux-pam
];

makeFlags = [
"DESTDIR=$(out)"
"PREFIX="
];

fixupPhase = ''
rm -rf $out/etc
'';
}
);
in
rec {
defaultApp = flake-utils.lib.mkApp { drv = defaultPackage; };
defaultPackage = lidm;
devShell = pkgs.mkShell { buildInputs = lidm.nativeBuildInputs ++ [ pkgs.clang-tools ]; };
}
);
}

0 comments on commit e3052ec

Please sign in to comment.