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 | 1 | +PREFIX ?= /usr/local |
| 2 | -BINDIR := $(PREFIX)/bin | 2 | +CC := gcc |
| 3 | +CFLAGS := -Wall -Wextra -Werror -std=c11 -pedantic -O2 | ||
| 3 | 4 | ||
| 4 | -CC := gcc | 5 | +SRC := src/main.c |
| 5 | -CFLAGS := -Wall -Wextra -Werror -std=c11 -pedantic -g | 6 | +TARGET := bin/sfetch |
| 6 | 7 | ||
| 7 | -SRC := src/main.c | 8 | +.PHONY: all clean install uninstall |
| 8 | -OBJ := build/main.o | ||
| 9 | -TARGET := bin/sfetch | ||
| 10 | - | ||
| 11 | -.PHONY: all clean run install uninstall | ||
| 12 | 9 | ||
| 13 | all: $(TARGET) | 10 | all: $(TARGET) |
| 14 | 11 | ||
| 15 | -$(TARGET): $(OBJ) | bin | 12 | +$(TARGET): $(SRC) |
| 16 | - $(CC) $(LDFLAGS) $^ -o $@ | 13 | + @mkdir -p bin |
| 17 | - | 14 | + $(CC) $(CFLAGS) $< -o $@ |
| 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) | ||
| 28 | 15 | ||
| 29 | -install: all | 16 | +install: $(TARGET) |
| 30 | - install -Dm755 $(TARGET) $(DESTDIR)$(BINDIR)/sfetch | 17 | + install -Dm755 $(TARGET) $(DESTDIR)$(PREFIX)/bin/sfetch |
| 31 | 18 | ||
| 32 | uninstall: | 19 | uninstall: |
| 33 | - rm -f $(DESTDIR)$(BINDIR)/sfetch | 20 | + rm -f $(DESTDIR)$(PREFIX)/bin/sfetch |
| 34 | 21 | ||
| 35 | clean: | 22 | clean: |
| 36 | rm -rf build bin | 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 | inputs = { | 4 | inputs = { |
| 5 | - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | 5 | + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; |
| 6 | - flake-utils.url = "github:numtide/flake-utils"; | ||
| 7 | }; | 6 | }; |
| 8 | 7 | ||
| 9 | outputs = { | 8 | outputs = { |
| 10 | self, | 9 | self, |
| 11 | nixpkgs, | 10 | nixpkgs, |
| 12 | - flake-utils, | 11 | + }: let |
| 13 | - }: | 12 | + supportedSystems = ["x86_64-linux" "aarch64-linux"]; |
| 14 | - flake-utils.lib.eachDefaultSystem ( | 13 | + forEachSupportedSystem = f: |
| 15 | - system: let | 14 | + nixpkgs.lib.genAttrs supportedSystems (system: |
| 16 | - pkgs = nixpkgs.legacyPackages.${system}; | 15 | + f { |
| 17 | - in { | 16 | + pkgs = import nixpkgs {inherit system;}; |
| 18 | - devShells.default = pkgs.mkShell { | 17 | + }); |
| 19 | - buildInputs = with pkgs; [ | 18 | + in { |
| 20 | - gnumake | 19 | + packages = forEachSupportedSystem ({pkgs}: { |
| 21 | - clang-tools | 20 | + default = pkgs.stdenv.mkDerivation { |
| 22 | - clang | 21 | + pname = "sfetch"; |
| 23 | - valgrind | 22 | + version = "0.1.3"; |
| 24 | - bear | ||
| 25 | - man-pages | ||
| 26 | - man-pages-posix | ||
| 27 | - ]; | ||
| 28 | 23 | ||
| 29 | - shellHook = '' | 24 | + src = self; |
| 30 | - source ~/.bashrc | 25 | + |
| 31 | - ''; | 26 | + nativeBuildInputs = with pkgs; [ gnumake gcc ]; |
| 32 | - }; | 27 | + |
| 33 | - } | 28 | + buildPhase = '' |
| 34 | - ); | 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 | * installation | 10 | * installation |
| 11 | ** first: | 11 | ** first: |
| 12 | - -make sure you have the dependencies required: | 12 | + make sure you have the dependencies required: |
| 13 | 1. a compiler (=gcc=, =clang=) | 13 | 1. a compiler (=gcc=, =clang=) |
| 14 | 2. gnumake (make) | 14 | 2. gnumake (make) |
| 15 | 3. a c lib (glibc, musl, etc...) | 15 | 3. a c lib (glibc, musl, etc...) |
| 16 | ** second: | 16 | ** second: |
| 17 | -#+BEGIN_SRC sh | 17 | +#+BEGIN_SRC sh :eval no |
| 18 | git clone https://codeberg.org/theidioticdev/sfetch | 18 | git clone https://codeberg.org/theidioticdev/sfetch |
| 19 | cd sfetch | 19 | cd sfetch |
| 20 | make PREFIX=$HOME/.local install # for your specific user | 20 | make PREFIX=$HOME/.local install # for your specific user |