chore: update flake.nix to be able to install sfetch declaratively
Browse files
+5 −0 .gitignore new file mode 100644
| @@ -0,0 +1,5 @@ | ||
| 1 | +.o | |
| 2 | +bin | |
| 3 | +build | |
| 4 | +.direnv | |
| 5 | + |
+12 −25 Makefile
| @@ -1,36 +1,23 @@ | ||
| 1 | -PREFIX ?= /usr/local | |
| 2 | -BINDIR := $(PREFIX)/bin | |
| 1 | +PREFIX ?= /usr/local | |
| 2 | +CC := gcc | |
| 3 | +CFLAGS := -Wall -Wextra -Werror -std=c11 -pedantic -O2 | |
| 3 | 4 | |
| 4 | -CC := gcc | |
| 5 | -CFLAGS := -Wall -Wextra -Werror -std=c11 -pedantic -g | |
| 5 | +SRC := src/main.c | |
| 6 | +TARGET := bin/sfetch | |
| 6 | 7 | |
| 7 | -SRC := src/main.c | |
| 8 | -OBJ := build/main.o | |
| 9 | -TARGET := bin/sfetch | |
| 10 | - | |
| 11 | -.PHONY: all clean run install uninstall | |
| 8 | +.PHONY: all clean install uninstall | |
| 12 | 9 | |
| 13 | 10 | all: $(TARGET) |
| 14 | 11 | |
| 15 | -$(TARGET): $(OBJ) | bin | |
| 16 | - $(CC) $(LDFLAGS) $^ -o $@ | |
| 17 | - | |
| 18 | -build/%.o: src/%.c | build | |
| 19 | - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ | |
| 20 | - | |
| 21 | -build bin: | |
| 22 | - mkdir -p $@ | |
| 23 | - | |
| 24 | --include build/main.d | |
| 25 | - | |
| 26 | -run: all | |
| 27 | - @./$(TARGET) | |
| 12 | +$(TARGET): $(SRC) | |
| 13 | + @mkdir -p bin | |
| 14 | + $(CC) $(CFLAGS) $< -o $@ | |
| 28 | 15 | |
| 29 | -install: all | |
| 30 | - install -Dm755 $(TARGET) $(DESTDIR)$(BINDIR)/sfetch | |
| 16 | +install: $(TARGET) | |
| 17 | + install -Dm755 $(TARGET) $(DESTDIR)$(PREFIX)/bin/sfetch | |
| 31 | 18 | |
| 32 | 19 | uninstall: |
| 33 | - rm -f $(DESTDIR)$(BINDIR)/sfetch | |
| 20 | + rm -f $(DESTDIR)$(PREFIX)/bin/sfetch | |
| 34 | 21 | |
| 35 | 22 | clean: |
| 36 | 23 | rm -rf build bin |
+39 −25 flake.nix
| @@ -1,35 +1,49 @@ | ||
| 1 | 1 | { |
| 2 | - description = "sfetch devshell"; | |
| 2 | + description = "A suckless system fetch utility written in C"; | |
| 3 | 3 | |
| 4 | 4 | inputs = { |
| 5 | - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | |
| 6 | - flake-utils.url = "github:numtide/flake-utils"; | |
| 5 | + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | |
| 7 | 6 | }; |
| 8 | 7 | |
| 9 | 8 | outputs = { |
| 10 | 9 | self, |
| 11 | 10 | nixpkgs, |
| 12 | - flake-utils, | |
| 13 | - }: | |
| 14 | - flake-utils.lib.eachDefaultSystem ( | |
| 15 | - system: let | |
| 16 | - pkgs = nixpkgs.legacyPackages.${system}; | |
| 17 | - in { | |
| 18 | - devShells.default = pkgs.mkShell { | |
| 19 | - buildInputs = with pkgs; [ | |
| 20 | - gnumake | |
| 21 | - clang-tools | |
| 22 | - clang | |
| 23 | - valgrind | |
| 24 | - bear | |
| 25 | - man-pages | |
| 26 | - man-pages-posix | |
| 27 | - ]; | |
| 11 | + }: let | |
| 12 | + supportedSystems = ["x86_64-linux" "aarch64-linux"]; | |
| 13 | + forEachSupportedSystem = f: | |
| 14 | + nixpkgs.lib.genAttrs supportedSystems (system: | |
| 15 | + f { | |
| 16 | + pkgs = import nixpkgs {inherit system;}; | |
| 17 | + }); | |
| 18 | + in { | |
| 19 | + packages = forEachSupportedSystem ({pkgs}: { | |
| 20 | + default = pkgs.stdenv.mkDerivation { | |
| 21 | + pname = "sfetch"; | |
| 22 | + version = "0.1.3"; | |
| 28 | 23 | |
| 29 | - shellHook = '' | |
| 30 | - source ~/.bashrc | |
| 31 | - ''; | |
| 32 | - }; | |
| 33 | - } | |
| 34 | - ); | |
| 24 | + src = self; | |
| 25 | + | |
| 26 | + nativeBuildInputs = with pkgs; [ gnumake gcc ]; | |
| 27 | + | |
| 28 | + buildPhase = '' | |
| 29 | + make | |
| 30 | + ''; | |
| 31 | + | |
| 32 | + installPhase = '' | |
| 33 | + make install PREFIX=$out | |
| 34 | + ''; | |
| 35 | + }; | |
| 36 | + }); | |
| 37 | + | |
| 38 | + devShells = forEachSupportedSystem ({pkgs}: { | |
| 39 | + default = pkgs.mkShell { | |
| 40 | + packages = with pkgs; [ gnumake gcc man-pages man-pages-posix]; | |
| 41 | + shellHook = '' | |
| 42 | + if [ -f ~/.bashrc ]; then | |
| 43 | + source ~/.bashrc | |
| 44 | + fi | |
| 45 | + ''; | |
| 46 | + }; | |
| 47 | + }); | |
| 48 | + }; | |
| 35 | 49 | } |
+49 −0 flake.nix-copy new file mode 100644
| @@ -0,0 +1,49 @@ | ||
| 1 | +{ | |
| 2 | + description = "A suckless system fetch utility written in C"; | |
| 3 | + | |
| 4 | + inputs = { | |
| 5 | + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | |
| 6 | + }; | |
| 7 | + | |
| 8 | + outputs = { | |
| 9 | + self, | |
| 10 | + nixpkgs, | |
| 11 | + }: let | |
| 12 | + supportedSystems = ["x86_64-linux" "aarch64-linux"]; | |
| 13 | + forEachSupportedSystem = f: | |
| 14 | + nixpkgs.lib.genAttrs supportedSystems (system: | |
| 15 | + f { | |
| 16 | + pkgs = import nixpkgs {inherit system;}; | |
| 17 | + }); | |
| 18 | + in { | |
| 19 | + packages = forEachSupportedSystem ({pkgs}: { | |
| 20 | + default = pkgs.stdenv.mkDerivation { | |
| 21 | + pname = "sfetch"; | |
| 22 | + version = "0.1.3"; | |
| 23 | + | |
| 24 | + src = self; | |
| 25 | + | |
| 26 | + nativeBuildInputs = with pkgs; [ gnumake gcc ]; | |
| 27 | + | |
| 28 | + buildPhase = '' | |
| 29 | + make | |
| 30 | + ''; | |
| 31 | + | |
| 32 | + installPhase = '' | |
| 33 | + make install PREFIX=$out | |
| 34 | + ''; | |
| 35 | + }; | |
| 36 | + }); | |
| 37 | + | |
| 38 | + devShells = forEachSupportedSystem ({pkgs}: { | |
| 39 | + default = pkgs.mkShell { | |
| 40 | + packages = with pkgs; [ gnumake gcc ]; | |
| 41 | + shellHook = '' | |
| 42 | + if [ -f ~/.bashrc ]; then | |
| 43 | + source ~/.bashrc | |
| 44 | + fi | |
| 45 | + ''; | |
| 46 | + }; | |
| 47 | + }); | |
| 48 | + }; | |
| 49 | +} |
+2 −2 readme.org
| @@ -9,12 +9,12 @@ just like suckless.org's projects (dwm, st, surf, etc...), sfetch is configured | ||
| 9 | 9 | |
| 10 | 10 | * installation |
| 11 | 11 | ** first: |
| 12 | - -make sure you have the dependencies required: | |
| 12 | + make sure you have the dependencies required: | |
| 13 | 13 | 1. a compiler (=gcc=, =clang=) |
| 14 | 14 | 2. gnumake (make) |
| 15 | 15 | 3. a c lib (glibc, musl, etc...) |
| 16 | 16 | ** second: |
| 17 | -#+BEGIN_SRC sh | |
| 17 | +#+BEGIN_SRC sh :eval no | |
| 18 | 18 | git clone https://codeberg.org/theidioticdev/sfetch |
| 19 | 19 | cd sfetch |
| 20 | 20 | make PREFIX=$HOME/.local install # for your specific user |