From 60257c85ea1e1a19acb20b80e17d027b2f16e487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20R=C3=B6ger?= Date: Fri, 21 Nov 2025 21:12:03 +0100 Subject: [PATCH] initial commit --- .envrc | 17 ++++++++++++++ .gitignore | 3 +++ CMakeLists.txt | 32 ++++++++++++++++++++++++++ app/mosh-me.cpp | 3 +++ flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 50 ++++++++++++++++++++++++++++++++++++++++ nix/mosh-me.nix | 19 +++++++++++++++ 7 files changed, 185 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 app/mosh-me.cpp create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/mosh-me.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..0e179fc --- /dev/null +++ b/.envrc @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# ^ make editor happy + +# +# Use https://direnv.net/ to automatically load the dev shell. +# + +if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" +fi + +watch_file nix/** +watch_file -- **/*.nix +# Adding files to git includes them in a flake +# But it is also a bit much reloading. +# watch_file .git/index .git/HEAD +use flake . --show-trace diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd60284 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.direnv/* +build +result diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..b19620f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,32 @@ + +cmake_minimum_required(VERSION 3.10) + +project( + mosh-me + VERSION 0.1.0 + LANGUAGES CXX) + +find_package(spdlog REQUIRED) +find_package(PkgConfig REQUIRED) +pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET + libavcodec + libavformat + libavutil +) + +# ############################################################################## + +add_executable(mosh-me ${PROJECT_SOURCE_DIR}/app/mosh-me.cpp) + +target_link_libraries(mosh-me PkgConfig::FFMPEG spdlog::spdlog) +target_compile_features(mosh-me PUBLIC cxx_std_23) +target_include_directories(mosh-me PRIVATE ${PROJECT_SOURCE_DIR}/include) + +install(TARGETS mosh-me) + +################################################################################ + +if(CMAKE_EXPORT_COMPILE_COMMANDS) + set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}) + set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}) +endif() diff --git a/app/mosh-me.cpp b/app/mosh-me.cpp new file mode 100644 index 0000000..d8551fb --- /dev/null +++ b/app/mosh-me.cpp @@ -0,0 +1,3 @@ +#include + +int main() { spdlog::info("Hello!!"); } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..287bc69 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1762980239, + "narHash": "sha256-8oNVE8TrD19ulHinjaqONf9QWCKK+w4url56cdStMpM=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "52a2caecc898d0b46b2b905f058ccc5081f842da", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1763618868, + "narHash": "sha256-v5afmLjn/uyD9EQuPBn7nZuaZVV9r+JerayK/4wvdWA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a8d610af3f1a5fb71e23e08434d8d61a466fc942", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1761765539, + "narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "719359f4562934ae99f5443f20aa06c2ffff91fc", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7385e80 --- /dev/null +++ b/flake.nix @@ -0,0 +1,50 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + }; + outputs = inputs @ {flake-parts, ...}: + flake-parts.lib.mkFlake {inherit inputs;} ({self, ...}: { + imports = []; + flake = { + overlays.mosh-me = final: prev: { + mosh-me = final.callPackage ./nix/mosh-me.nix {}; + }; + }; + systems = [ + "x86_64-linux" + ]; + perSystem = { + pkgs, + system, + self', + ... + }: { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ + self.overlays.mosh-me + ]; + config = {}; + }; + + packages.default = pkgs.mosh-me; + packages.mosh-me = pkgs.mosh-me; + + devShells.default = self'.devShells.mosh-me; + devShells.mosh-me = pkgs.mkShellNoCC { + shellHook = '' + export CMAKE_EXPORT_COMPILE_COMMANDS=ON + export CMAKE_BUILD_TYPE=Debug + export CMAKE_GENERATOR=Ninja + ''; + packages = [ + pkgs.clang-tools + pkgs.cmake-language-server + pkgs.gdb + ]; + inputsFrom = [pkgs.mosh-me]; + }; + }; + }); +} diff --git a/nix/mosh-me.nix b/nix/mosh-me.nix new file mode 100644 index 0000000..d3a1a78 --- /dev/null +++ b/nix/mosh-me.nix @@ -0,0 +1,19 @@ +{ + cmake, + lib, + ninja, + spdlog, + stdenv, + pkg-config, + ffmpeg, +}: +stdenv.mkDerivation (finalAttrs: { + name = "mosh-me"; + src = ../.; + nativeBuildInputs = [cmake ninja pkg-config]; + buildInputs = [ffmpeg spdlog]; + cmakeFlags = [ + (lib.cmakeBool "BUILD_TESTING" finalAttrs.doCheck) + ]; + doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; +})