diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 8e9bfff..45d0ca4 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -91,3 +91,18 @@ jobs: run: | FEATURES="-ipc-sandbox -network-sandbox -pid-sandbox -mount-sandbox -usersandbox -userpriv" \ ebuild /var/db/repos/localrepo/app-misc/lsu/lsu-9999.ebuild fetch unpack compile test + + nix: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Build Nix package + run: | + docker run --rm \ + -v "${{ github.workspace }}":/repo \ + -w /repo \ + nixpkgs/nix-flakes \ + sh -c 'git config --global --add safe.directory /repo && nix build .#' diff --git a/README.md b/README.md index 0813c67..5ad683f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,9 @@ [![Codecov](https://codecov.io/gh/l5yth/lsu/graph/badge.svg)](https://codecov.io/gh/l5yth/lsu) [![GitHub Release](https://img.shields.io/github/v/release/l5yth/lsu)](https://github.com/l5yth/lsu/releases) [![Crates.io](https://img.shields.io/crates/v/lsu.svg)](https://crates.io/crates/lsu) -[![AUR Version](https://img.shields.io/aur/version/lsu-bin)](https://aur.archlinux.org/packages/lsu-bin) +[![AUR Version](https://img.shields.io/aur/version/lsu-bin?logo=archlinux)](https://aur.archlinux.org/packages/lsu-bin) +[![Nix Flake](https://img.shields.io/badge/nix-flake-5277C3?logo=nixos)](https://github.com/l5yth/lsu/blob/main/flake.nix) +[![Gentoo](https://img.shields.io/badge/gentoo-ebuild-54487A?logo=gentoo)](https://github.com/l5yth/lsu/tree/main/packaging/gentoo) [![Top Language](https://img.shields.io/github/languages/top/l5yth/lsu)](https://github.com/l5yth/lsu) [![License: Apache-2.0](https://img.shields.io/github/license/l5yth/lsu)](https://github.com/l5yth/lsu/blob/main/LICENSE) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..bb1d357 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1772624091, + "narHash": "sha256-QKyJ0QGWBn6r0invrMAK8dmJoBYWoOWy7lN+UHzW1jc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "80bdc1e5ce51f56b19791b52b2901187931f5353", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..5d7925e --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +# Copyright (c) 2026 l5yth +# SPDX-License-Identifier: Apache-2.0 +{ + description = "Terminal UI for systemd services and their journal"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = { self, nixpkgs }: + let + systems = [ + "x86_64-linux" + "aarch64-linux" + "armv6l-linux" + "armv7l-linux" + ]; + forAllSystems = f: nixpkgs.lib.genAttrs systems f; + in { + packages = forAllSystems (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in { + default = pkgs.callPackage ./packaging/nix/default.nix { }; + }); + + devShells = forAllSystems (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in { + default = pkgs.mkShell { + inputsFrom = [ self.packages.${system}.default ]; + packages = [ pkgs.cargo pkgs.rustfmt pkgs.clippy ]; + }; + }); + }; +} diff --git a/packaging/nix/default.nix b/packaging/nix/default.nix new file mode 100644 index 0000000..4c75034 --- /dev/null +++ b/packaging/nix/default.nix @@ -0,0 +1,26 @@ +# Copyright (c) 2026 l5yth +# SPDX-License-Identifier: Apache-2.0 +# +# Standalone derivation for lsu. +# Can be called directly from a flake or from nixpkgs: +# pkgs.callPackage ./packaging/nix/default.nix { } +{ lib, rustPlatform }: + +rustPlatform.buildRustPackage { + pname = "lsu"; + version = (lib.importTOML ../../Cargo.toml).package.version; + + src = lib.cleanSource ../..; + + cargoLock.lockFile = ../../Cargo.lock; + + meta = { + description = "Terminal UI for systemd services and their journal"; + homepage = "https://github.com/l5yth/lsu"; + license = lib.licenses.asl20; + maintainers = [ ]; + # lsu shells out to systemctl/journalctl; systemd is Linux-only. + platforms = lib.platforms.linux; + mainProgram = "lsu"; + }; +}